ESP-Now support for ESP32 (and ESP8266)

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: ESP-Now support for ESP32 (and ESP8266)

Post by davef » Mon Apr 04, 2022 8:18 pm

Most of the boards I have been using are ESP32_DevKitc_V4 and they are not SPIRAM. Have I misunderstood?

BetterAutomations
Posts: 83
Joined: Mon Mar 20, 2017 10:22 pm

Re: ESP-Now support for ESP32 (and ESP8266)

Post by BetterAutomations » Mon Apr 04, 2022 10:29 pm

davef wrote:
Mon Apr 04, 2022 8:14 pm
However, now that I have some idea of what you mean by "bricked" ... where do those errors appear? In rshell?
I see the errors in a serial console, over picocom. I never have these errors otherwise.

Was able to flash it back to the official firmware and the module I bricked sometimes works again, sometimes fails with the same error.
Last edited by BetterAutomations on Mon Apr 04, 2022 10:33 pm, edited 1 time in total.

BetterAutomations
Posts: 83
Joined: Mon Mar 20, 2017 10:22 pm

Re: ESP-Now support for ESP32 (and ESP8266)

Post by BetterAutomations » Mon Apr 04, 2022 10:31 pm

davef wrote:
Mon Apr 04, 2022 8:18 pm
Most of the boards I have been using are ESP32_DevKitc_V4 and they are not SPIRAM. Have I misunderstood?
Depends if the DevKitc contains a WROOM, SOLO, or WROVER module. I sought out the ones with the WROVER modules because those all have SPIRAM.

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: ESP-Now support for ESP32 (and ESP8266)

Post by davef » Mon Apr 04, 2022 11:54 pm

Right, my SPIRAM variants are DevKitC-V1E.

Try raising an issue on his GitHub.

User avatar
glenn20
Posts: 132
Joined: Mon Jun 04, 2018 10:09 am

Re: ESP-Now support for ESP32 (and ESP8266)

Post by glenn20 » Wed Apr 06, 2022 3:18 am

Hi All,

Firstly, I'm sorry to have been on radio silence for the last few months. Some health issues, starting a new job and misconfigured email meant I hadn't been paying attention. I expect to be back online regularly (although, perhaps with less duty cycle than I had managed through most of 2020 and 2021).

I will respond to a few of the issues raised here shortly...

And I want to acknowledge the great work by the community in supporting each other for the last few months (esp. davef :-).

Cheers,
Glenn.

User avatar
glenn20
Posts: 132
Joined: Mon Jun 04, 2018 10:09 am

Re: ESP-Now support for ESP32 (and ESP8266)

Post by glenn20 » Wed Apr 06, 2022 3:36 am

Wifi Failure persisting across re-boots (was "Bricking") by @BetterAutomations

Thanks for reporting these issues. It is certainly behaviour I have never seen before and am struggling to replicate. However, I don't currently have any WROVER modules to test.

If I understand correctly, after some time of use the wifi radio appears to become inoperable and this persists after reboots (soft or hard??).

Some comments:
  • I have seen circumstances where the wifi radio operation is not fully recovered after a soft reboot. A soft reboot reloads the micropython interpreter and may not fully re-initilise the hardware. Also, it is not clear to me that the low-lying espressif code is fully re-initialsied on soft reboot (eg. some low-level memory buffers may not be freed in all circumstance). After a failure, you should use a power cycle or a machine.reset() to force a hard reset. If that does not recover the wifi function there is indeed some problem with initialising the hardware after the failure mode.
  • Although I may have lost track a little - the error messages you reported indicated errors in allocating wifi buffers which may be consistent with the above. If those messages persist after a hard reset then something else is going on.
Let me know if I have misunderstood, or if you have any further tips on how to replicate this error.

(BTW - it is misleading to call this bricking - which implies the device is unrecoverable even by re-flashing, while it seems from your posts that the device remains fully functional except for the wifi remaining inoperable across reboots).
Last edited by glenn20 on Wed Apr 06, 2022 3:53 am, edited 1 time in total.

User avatar
glenn20
Posts: 132
Joined: Mon Jun 04, 2018 10:09 am

Re: ESP-Now support for ESP32 (and ESP8266)

Post by glenn20 » Wed Apr 06, 2022 3:51 am

Hi Mike,
MMliam wrote:
Sun Feb 27, 2022 5:41 pm
Some how I missed your post; getting a bit confused between GitHub and microPython boards.
I'll try the your suggestion below.
I've never seen this construct before: w0, w1 = (network.WLAN(i) for i in (0, 1)). Is it documented some where that indicates the STA is the first one designated "0" and the AP is the second, designated "1"? Probably has to do with the fact that I don't actually understand what [network.STA_IF] is doing in the instruction [netObj = network.WLAN(network.STA_IF)]
(Apologies for the even slower response ;).

network.STA_IF is just a constant defined in the networking module and is equal to 0. network.AP_IF is defined as equal to 1. Of course it is better coding practice to use the symbolic representations, but I sometimes use 0 and 1 as a shortcut. These constants follow the convention of equivalent constants in the espressif networking code.

So, (network.WLAN(i) for i in (0, 1)) is a python generator expression which yields the STA_IF interface object first and the AP_IF interface object second. These are then assigned to w0 and w1 respectively by python tuple unpacking, so it is equivalent to:

w0, w1 = network.WLAN(network.STA_IF), network.WLAN(network.AP_IF)

User avatar
glenn20
Posts: 132
Joined: Mon Jun 04, 2018 10:09 am

Re: ESP-Now support for ESP32 (and ESP8266)

Post by glenn20 » Wed Apr 06, 2022 4:02 am

BetterAutomations wrote:
Wed Mar 30, 2022 5:08 pm
I think I see why. I cloned glenn20's MicroPython fork which I assumed contained his ESPnow code, but it does not. I'll try to merge from his pull request instead.

Edit: Confirmed, that was the problem. I can now import espnow.

Code: Select all

cdevidal@ubuntuvm:~/glenn20/ports/esp32$ ls ~/glenn20/docs/library/espnow.rst
ls: cannot access '/home/cdevidal/glenn20/docs/library/espnow.rst': No such file or directory
cdevidal@ubuntuvm:~/glenn20/ports/esp32$
My espnow code is on the espnow-g20 branch of my fork of the micropython repo. That is what is referenced from PR6515. So, you can clone from either the PR or the espnow-g20 branch.

User avatar
glenn20
Posts: 132
Joined: Mon Jun 04, 2018 10:09 am

Re: ESP-Now support for ESP32 (and ESP8266)

Post by glenn20 » Wed Apr 06, 2022 4:07 am

BetterAutomations wrote:
Wed Mar 30, 2022 4:10 am
BetterAutomations wrote:
Wed Mar 30, 2022 2:12 am
So is pairing an accessory device without encryption as simple as this?
Just tested it. I was almost correct.
That's right, the underlying Espressif espnow code does not permit sending empy messages. You need at least one byte in the message.

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: ESP-Now support for ESP32 (and ESP8266)

Post by davef » Wed Apr 06, 2022 4:15 am

Welcome back! Did the RSSI functionality work its way into the code? I would test it myself if the units were more accessible.
Thanks,
Dave

Post Reply