ESP-Now support for ESP32 (and ESP8266)

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
User avatar
glenn20
Posts: 132
Joined: Mon Jun 04, 2018 10:09 am

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

Post by glenn20 » Tue Dec 07, 2021 7:37 am

davef wrote:
Sun Dec 05, 2021 3:10 am
Anybody using lightsleep() on a ESP32 and the latest ESP-Now image?

Occasionally the unit locks-up and doesn't recover with the ESP watchdog timer. The code is here:
https://github.com/davefes/ESP-Now-repe ... /remote.py with all the watchdog stuff enabled, in case that might supply a clue.
I took a quick look and couldn't see any obvious issue with your code. You may be uncovering some espnow bug - or some other micropython issue. The latest images are built from the master branch and may have some instabilities. It's been a bit of extra effort to support the newer espnow fixes/features on master and also on the v1.17 release because there have been some significant changes to micropython since v1.17. I am guessing there will be a v1.18 some time soon.

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 » Tue Dec 07, 2021 8:03 am

Hi Glenn,

Thanks for the response.

I am testing the remote in the lounge for a few days as well as blinking an LED (once a minute) to tell me if the loop stops running.

It could be a path issue as there is a tree in the way and the leaves are growing well with all our Spring rain.

As I have some new 18650 cells in the unit I could do a utime.sleep(60) instead of the lightsleep(60000) if I continue to have problems.

Also, one can't rule-out the actual ESP32 dev board I am using.

User avatar
Zoland
Posts: 20
Joined: Wed Jan 23, 2019 2:12 pm
Location: Russia, Altai

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

Post by Zoland » Tue Dec 07, 2021 9:52 am

glenn20 wrote:
Tue Dec 07, 2021 12:15 am
@zoland: do you have links to your Smesh code? I couldn't find it in your github public repos.
I will publish it in the coming days after the technical cleaning of the code

Glenn, I have a need to check for the presence of a peer, now I do it through 'try:', but I would just like to make a request like 'my_peer in en.peers_list'. Is it possible?

User avatar
Zoland
Posts: 20
Joined: Wed Jan 23, 2019 2:12 pm
Location: Russia, Altai

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

Post by Zoland » Wed Dec 08, 2021 3:09 pm

IN DOCs

1. Which values return ESPNow.write(b) ?

2. Where I can set sync parameter in ESPNow.send(mac, msg[, sync]) if I not want waiting for response?
True: (default) send msg to the peer(s) and wait for a response (or not).

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 » Sat Dec 18, 2021 6:36 pm

Zoland,

A snippet of code that Glenn wrote that is in my ESPNow project.

Code: Select all

        w0.active(True) #  turn on radio only when needed
     #  if you want to save more battery, set sync=False
     #  at cost of not knowing if message was received.
        retval = e0.send(repeater_mac, status, True)
        w0.active(False)
So, not waiting should be:

Code: Select all

 retval = e0.send(repeater_mac, status, False)
which I should change in my code as I don't do anything with retval.

Barneybear
Posts: 8
Joined: Tue Dec 21, 2021 1:30 pm

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

Post by Barneybear » Tue Dec 21, 2021 1:37 pm

Hi Glenn thank you for your work, I wish to develop a project via webrepl and esp now on an esp8266. I have installed your latest .bin and everything works until I try webrepl setup which after completion makes the 8266 go into a constant reboot loop. Can the two functions coexist or is it a bug. I apologize if it has been asked before, but could not get any search hits on the matter.
All the best

MMliam
Posts: 121
Joined: Mon May 07, 2018 1:08 pm

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

Post by MMliam » Tue Dec 21, 2021 1:51 pm

Hi Glenn,

I've been discussing an issue with davef; that being setting a fixed channel in station-mode for an ESP8266. Dave suggested that I try your build the includes ESPNow, as there was an example posted demonstrating that it was indeed possible:
https://micropython-glenn20.readthedocs ... -operation
EXCERPT:
w0 = network.WLAN(network.STA_IF)
w0.active(True) # Set channel will fail unless Active
w0.config(channel=6)
Flashed your build:
20210903_espnow-g20-v1.17
Actual file name: firmware-esp8266-GENERIC_1M (581KB)

However, I tried this using an ESP-01s, when it hits the channel set results in this error:
File "main.py", line 18, in
OSError: AP required

MicroPython v1.17-12-g26e539a1b on 2021-09-03; ESP module (1M) with ESP8266
Type "help()" for more information.
The error indicating that the set-channel requires Access-Point-mode, not Station-mode.

dave tried this with an ESP32 and had success; is there some limitation with the build for the ESP8266?

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 » Tue Dec 21, 2021 6:09 pm

Barneybear and MMliam,

I haven't tried myself but maybe looking through the port for the ESP32 and the ESP8266 here:
https://github.com/glenn20/micropython/ ... -g20/ports
might turn-up the differences between the two.

Reading back through the old postings, about pages 13, 14 I see another comment, "keyword arguments are left out of some ESP8266 stuff to save space".

Barneybear ... README.md for the ESP8266 says webrepl should be functional.

MMliam
Posts: 121
Joined: Mon May 07, 2018 1:08 pm

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

Post by MMliam » Wed Dec 22, 2021 1:45 am

Thanks dave, but drawing a blank on differences.

Who do you make feature requests to? I haven't seen any formal link. Quite frankly allowing a station to fix it's channel will make re-connection from deep-sleep much quicker, and remove the significant re-connection time variability.

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 Dec 22, 2021 2:30 am

Feature requests ... well the one I asked for is on the GitHub issues page. I know he has done something as RSSI is now in the docs. I believe he is doing some tests before adding it to his image(s).

I suspect that something would have to be removed to add your feature, which might make someone else unhappy.

Unfortunately, you just have to wait and hope that something can be done.

Post Reply