second this, I'm having problems with ESP now on the latest release (cardputer and DIN meter), likely something wrong but I've tried a lot of things.
if anyone could confirm they have this part working that would be helpful for me?
thanks!
second this, I'm having problems with ESP now on the latest release (cardputer and DIN meter), likely something wrong but I've tried a lot of things.
if anyone could confirm they have this part working that would be helpful for me?
thanks!
Hi everyone!
having some problems with ESP now on the latest micro python UIFlow (2.3.9).
the simplest program I have is below, stripped right to the basics (just a loopback)
problem is the sends go through ok i.e. no exceptions but the receiver is not picking anything up.
I have tried a lot of things but no luck, any ideas would be greatly appreciated!
if anyone is running obvs change Mac address.
Thanks!!!
import network
from m5espnow import * # Correct import for UIFlow firmware
from m5espnow import M5ESPNow
import time
# Callback: Fires automatically on incoming messages
def espnow_recv_callback(espnow_obj):
sender_mac, data = espnow_obj.recv_data() # sender_mac is hex str, data is bytes
if data is not None:
try:
msg_text = data.decode('utf-8')
except:
msg_text = repr(data)
print(f"[RECEIVED from {sender_mac}] {msg_text}")
# 1. WiFi setup (must be in this order for stability)
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.config(pm=0) # Disable power saving
wlan.disconnect() # Force disconnect to free radio
wlan.config(channel=11) # Fixed channel (try 6 or 11 if interference)
time.sleep(0.5) # Settle time
# 2. M5ESPNOW setup
e = M5ESPNow(11) # Create instance (default wifi_ch=0)
e.set_irq_callback(espnow_recv_callback) # Register callback
e.active(True) # Activate ESP-NOW
# 3. Get own MAC as hex string (no colons, lowercase)
my_mac_bytes = wlan.config('mac')
my_mac_hex = ''.join(f'{b:02x}' for b in my_mac_bytes)
print("My MAC:", my_mac_hex)
# 4. Add self as peer (peer_mac: str, peer_id: 1, ifidx: 0, encrypt: False)
e.set_add_peer(my_mac_hex, 1, 0, False)
print("=== Starting loopback test (watch for RECEIVED lines) ===")
# 5. Send loop to self (peer_id=1)
counter = 0
while counter < 5:
counter += 1
msg = f"Hello from Cardputer! #{counter}".encode('utf-8') # Bytes payload
success = e.send_data(1, msg) # Send to peer_id=1 (self)
print(f"Sent #{counter} (success: {success})")
time.sleep(2) # Wait for callback to fire