''' ESPNow Receiver Receives 6 floats for ESPNow and prints the result to the serial port 2026-01-31 mchris ''' import network import espnow import struct import time # 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) print("timestamp, temperature, pressure, humidity, vbat, counter") while True: host, msg = e.recv() if msg: # msg == None if timeout in recv() #print(host, msg) floats = struct.unpack('<5f', msg) t = time.localtime() timestamp = "{:02d}:{:02d}:{:02d}".format(t[3], t[4], t[5]) txt=timestamp for f in floats: txt=txt+", "+str(f) print(txt) if msg == b'end': break