I was recantly experimenting with espnow in micropython. Sudenly I rann Into A Problem wenn trying to run this code:
import network, espnow, time
wlan_sta = network.WLAN(network.STA_IF)
wlan_sta.active(True)
e = espnow.ESPNow()
e.active(True)
peer = b'\xff\xff\xff\xff\xff\xff' # MAC
e.add_peer(peer)
while True:
e.send(peer, "ESP")
time.sleep(1.1) # Sekunden
i get the Error OSError: -3
The Code worked on my Esp32 but not on the 8266 no clue why. I tried reflashing my esp but that did not help either.
According to the documentation you need to call
wla_sta.disconnect()after settingwlan_sta.active(True). This is the example from the docs:If I run that example as written (well, correcting the second call to
e.sendas shown in the above code) and the corresponding receiver code, it all works just fine on a pair of esp8266's runningv1.19.1-espnow-6-g44f65965b.Update I think your problem is that the esp8266 may not support the broadcast address. While the documentation suggests that the esp8266 should be able to send to the broadcast address:
It appears that this isn't the case. I'm able to use the example code from the docs when operating in unicast mode, but attempting to call
e.add_peerwith the broadcast address results in the same error you've reported.I've opened issue #11 with this problem.