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 » Wed Dec 16, 2020 7:00 am

Thanks for the heads-up and for the pre-compiled image. I have a link using UDP on two ESP-01S that I might change to ESP-NOW to test.

I hope that I can change one end of the link to normal WiFi mode to send alarms and datalogs to a 3G hotspot. I do not need simultaneous operation.

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 16, 2020 8:45 am

Is the esp8266 image generic_1M? The image with <make board=GENERIC_1M> that I was able to build is 623524 and yours at 593348.

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 Dec 16, 2020 9:41 am

davef wrote:
Wed Dec 16, 2020 6:19 am
Hi Glenn,

Thanks for your work on this implementation. As soon as some ESP-07S arrive I will try out firmware-combined.bin

I hadn't seen that link. Would it not require quite a few changes for a different compiler? I followed some instructions that I found for building esp-open-sdk on this site, mainly to set up the toolchain, and then modified it to build your fork.
Ah - of course - the link I provided is to instructions for building fro the ESP32.

The instructions I used for the ESP8266 are at https://github.com/micropython/micropyt ... ts/esp8266, which is much closer to the instructions you used.

uCTRL
Posts: 47
Joined: Fri Oct 12, 2018 11:50 pm

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

Post by uCTRL » Wed Dec 16, 2020 10:29 pm

Glenn, thank you and well done for implementing ESP-NOW. Have been waiting for this for a long time, could be a game changer for me in using ESP's with micropython.

Sorry haven't had a chance to look at all of the documentation or play with it yet, but is it possible to assign arbitrary Mac address rather than using factory assigned Mac address?
This has been discussed and addressed on some other platforms including Arduino.

one example https://randomnerdtutorials.com/get-cha ... s-arduino/

Reason for arbitrary Mac address assignment is more flexibility when configuring the network and more importantly if there is a need to replace actual ESP chip in a particular node due to fault or whatever. New ESP chip/module can just drop in and Arbitrary mac address is totally controlled by the firmware developed for that node.

Best Regards
John

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

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

Post by glenn20 » Thu Dec 17, 2020 2:53 am

davef wrote:
Wed Dec 16, 2020 8:45 am
Is the esp8266 image generic_1M? The image with <make board=GENERIC_1M> that I was able to build is 623524 and yours at 593348.
Yes, it is GENERIC_1M. I had to squeeze down the code to make it fit in the standard compile text size.

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

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

Post by glenn20 » Thu Dec 17, 2020 3:14 am

uCTRL wrote:
Wed Dec 16, 2020 10:29 pm
Sorry haven't had a chance to look at all of the documentation or play with it yet, but is it possible to assign arbitrary Mac address rather than using factory assigned Mac address?
Hi John.

You can set the mac address using the standard esp32 network code (I haven't tested this personally. I believe it should work), eg:

Code: Select all

import network
w = network.WLAN(network.STA_IF)
w.config(mac=b'\xaa\xaa\xaa\xaa\xaa\xaa')
Then proceed to use the espnow module with that interface, eg:

Code: Select all

from esp import espnow
e  = espnow.ESPNow()
e.init()
w.active(True)
I hope the espnow module is useful for you - let me know if there is any important functionalty not in the current implementation.

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 » Sun Dec 20, 2020 10:56 pm

ESP8266 ESPNow support now merged into micropython PR#6515

I have update the code base for PR #6515 (https://github.com/micropython/micropython/pull/6515).

The update includes the esp8266 support, some code simplifications for the esp32 support and some documentaton fixes.

So ESP32 and ESP8266 users can get their code from the same place now (https://github.com/glenn20/micropython/tree/espnow-g20).

As always, if you find some problems, let me know.

Note that I have squashed some commits on the espnow-g20 branch. Apologies if this disrupts anyone else using the branch. I am trying to keep the PR as clean as possible in the hope that is does get merged into the main micropython code base.

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 22, 2020 5:42 am

I am generating a brief description of the available methods from https://github.com/glenn20/micropython/ ... ee466e7e75

Is there an automated way of getting the methods available rather than manually editing that file?

Thanks,
Dave

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 22, 2020 5:51 am

@davef - not that I am aware of. I document the methods in the docs/library/espnow.rst file. You can build those doc's with

Code: Select all

cd docs ; make html
. The latest version clarifies what is available on esp8266 and esp32.

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 22, 2020 6:34 am

Xubuntu said I needed to install sphinxsearch, but sphinx_build is nowhere to be found.

I'll do more reading later. For now I'll just edit the file.

Thanks,
Dave

Post Reply