''' CYD (Cheap Yellow Display) ESP32 receiver showing remote BME280 values Communication Method: ESPNOW external libraries: https://github.com/rdagger/micropython-ili9341 2026-01-26 mchris ''' import network import espnow import struct 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) x=10;y=20 display.draw_text8x8(x, y, "REMOTE BME280", YELLOW, background=BLACK, rotate=0) # A WLAN interface must be active to send()/recv() sta = network.WLAN(network.WLAN.IF_STA) sta.active(True) sta.disconnect() # Because ESP8266 auto-connects to last Access Point print('MAC:', ':'.join(['%02x' % b for b in sta.config('mac')])) e = espnow.ESPNow() e.active(True) while True: host, msg = e.recv() if msg: if msg == b'end': print('End received') break if len(msg) == 20: # 5 floats * 4 bytes floats = struct.unpack('<5f', msg) print('Received floats:', floats) temperature=floats[0] pressure=floats[1] display.draw_text8x8(10,52, 'remote temperature: ', WHITE, background=BLACK) display.draw_text8x8(180,52, str(temperature), WHITE, background=BLUE) display.draw_text8x8(10,68, 'remote pressure: ', WHITE, background=BLACK) display.draw_text8x8(180,68, str(pressure), WHITE, background=BLUE)