''' CYD display test showing ESP chip temperature external libraries: https://github.com/rdagger/micropython-ili9341 2026-01-25 mchris ''' from ili9341 import Display, color565 import esp32 from machine import Pin, SPI import time display_spi = SPI(1, baudrate=80000000, sck=Pin(14), mosi=Pin(13)) # The library needs a reset pin, which does not exist on this board display = Display(display_spi, dc=Pin(2), cs=Pin(15), rst=Pin(15),rotation=90) # Turn on display backlight backlight = Pin(21, Pin.OUT) backlight.on() DARKGRAY=color565(80, 80, 80) BLUE=color565(0, 0, 255) GREEN=color565(0, 255, 0) WHITE=color565(255, 255, 255) YELLOW=color565(0, 255, 255) BLACK=color565(0, 0, 0) display.clear(DARKGRAY) x1=10;x2=160;y1=100;y2=100 display.draw_line(x1, y1, x2, y2, GREEN) x=20;y=20 display.draw_text8x8(x, y, "CHIP TEMPERATURE", YELLOW, background=BLACK, rotate=0) x=40;y=40;w=80;h=30; display.fill_rectangle(x, y, w, h, BLUE) counter=0 while True: temp_raw = esp32.raw_temperature() chipTemperature = round((temp_raw - 32) * 5/9, 1) display.draw_text8x8(62,52, str(chipTemperature), WHITE, background=BLUE) display.draw_text8x8(140,103, str(counter), GREEN, background=DARKGRAY) counter=counter+1 time.sleep_ms(1000)