ESP-Now support for ESP32 (and ESP8266)
Re: ESP-Now support for ESP32 (and ESP8266)
A note on reliable delivery of incoming espnow messages on ESP8266
I just wanted to clarify a potential cause of unreliable receiving of espnow messages on ESP8266 devices. As documented at https://micropython-glenn20.readthedocs ... -operation, the radio is automaticaly put to sleep periodically when the STA_IF interface is connected to an external Access Point (power saving mode). This is a function of the Espressif wifi libraries.
ESP8266 devices automatically remember and reconnect to their last Access Point once the STA_IF interface is set active after reboot, meaning your device may connect to an Access Point and enter the power-saving mode without you realising it. Inserting network.WLAN(network.STA_IF).disconnect() after you activate the STA_IF interface will help prevent this.
Eg. I had to add this to the tests in tests/multi-espnow/*.py to make my tests work reliably on my ESP8266 test modules.
(I will put a note in the docs, but wanted to highlight it here, as it may explain some issues users have been reporting.)
I just wanted to clarify a potential cause of unreliable receiving of espnow messages on ESP8266 devices. As documented at https://micropython-glenn20.readthedocs ... -operation, the radio is automaticaly put to sleep periodically when the STA_IF interface is connected to an external Access Point (power saving mode). This is a function of the Espressif wifi libraries.
ESP8266 devices automatically remember and reconnect to their last Access Point once the STA_IF interface is set active after reboot, meaning your device may connect to an Access Point and enter the power-saving mode without you realising it. Inserting network.WLAN(network.STA_IF).disconnect() after you activate the STA_IF interface will help prevent this.
Eg. I had to add this to the tests in tests/multi-espnow/*.py to make my tests work reliably on my ESP8266 test modules.
(I will put a note in the docs, but wanted to highlight it here, as it may explain some issues users have been reporting.)
Re: ESP-Now support for ESP32 (and ESP8266)
With the RSSI capability in the v1.18 versions of the ESP32 I have posted at:
https://github.com/davefes/ESPNow-Range-Testing
a sender and receiver application using a display OLED to give 5 second updates of RSSI.
https://github.com/davefes/ESPNow-Range-Testing
a sender and receiver application using a display OLED to give 5 second updates of RSSI.
Re: ESP-Now support for ESP32 (and ESP8266)
Good evening,
MycroPython is new for me, I only have some experience with C (Arduino IDE).
For school a school project I need to let 2 ESP32 communicate with each other and I have to do it with MicroPython.
So I did find EspNow, but I,' stuck at the very beginning.
I get the 'ImportError: cannot import name espnow' frase over and over again.
I read al the stuff about the error, modules en function...
But I can't find how this all supose to work...
Can someone tell me how to solve this?
Oh, before I forget: I'm using 2 vroom esp32's, I'm using uPyCraft V1.1 and the script I'm trying is one with the sender and receiver.
MycroPython is new for me, I only have some experience with C (Arduino IDE).
For school a school project I need to let 2 ESP32 communicate with each other and I have to do it with MicroPython.
So I did find EspNow, but I,' stuck at the very beginning.
I get the 'ImportError: cannot import name espnow' frase over and over again.
I read al the stuff about the error, modules en function...
But I can't find how this all supose to work...
Can someone tell me how to solve this?
Oh, before I forget: I'm using 2 vroom esp32's, I'm using uPyCraft V1.1 and the script I'm trying is one with the sender and receiver.
Re: ESP-Now support for ESP32 (and ESP8266)
Good Morning Lucje and welcome to micropython.Lucje wrote: ↑Sat May 14, 2022 4:24 pmGood evening,
MycroPython is new for me, I only have some experience with C (Arduino IDE).
For school a school project I need to let 2 ESP32 communicate with each other and I have to do it with MicroPython.
So I did find EspNow, but I,' stuck at the very beginning.
It is a hard to tell from your message exactly what you have tried, but I will make a guess. Do your get this error message when you type in the command
Code: Select all
from esp import espnow
You can get micropython images with espnow support at:
https://github.com/glenn20/micropython-espnow-images
Hopefully that will fix your problem.... Untill the next one
![Wink ;)](./images/smilies/icon_e_wink.gif)
Cheers and good luck.
Re: ESP-Now support for ESP32 (and ESP8266)
Thanks for your message Yeti,
(I'm not able yet to aswer messages.)
I'm aware about the fact that the EspNow isn't standard yet.
My setup is for the school subject is 'prototyping and programming', and we are encouraged to think out of the box.
So, that's why I'm try this path.
Have a nice Sunday![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
(I'm not able yet to aswer messages.)
I'm aware about the fact that the EspNow isn't standard yet.
My setup is for the school subject is 'prototyping and programming', and we are encouraged to think out of the box.
So, that's why I'm try this path.
Have a nice Sunday
![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
Re: ESP-Now support for ESP32 (and ESP8266)
Thanks Glenn,glenn20 wrote: ↑Sat May 14, 2022 5:41 pm
Good Morning Lucje and welcome to micropython.
It is a hard to tell from your message exactly what you have tried, but I will make a guess. Do your get this error message when you type in the command
If so, then I suspect you are running a micropython image on your esp32 which does not have espnow support. The micropython firmware images from micropython.org do not include espnow support.Code: Select all
from esp import espnow
You can get micropython images with espnow support at:
https://github.com/glenn20/micropython-espnow-images
Hopefully that will fix your problem.... Untill the next one.
Cheers and good luck.
Your answer did help.
I had to try all the firmwares because mine wasn't listed.
I'm using a EspVroom32 devkit1 and the one with Atom in the name seems to work with my board.
I still have a little question though, I do have oneway communication now, is twoway also possible?
Example: One board asks and the other answers.
Greetings Lucje
Re: ESP-Now support for ESP32 (and ESP8266)
I only use ESP32 Wroom-32U and https://github.com/glenn20/micropython- ... ENERIC.binworks for me. Did you try that one?
Maybe, post a link to your specific hardware.
Study the docs at https://micropython-glenn20.readthedocs ... spnow.htmlspecifically the https://micropython-glenn20.readthedocs ... iving-datapart. For an example go here:
https://github.com/davefes/ESP-Now-repe ... water_tank and look at the repeater code.
Have fun!
Maybe, post a link to your specific hardware.
Study the docs at https://micropython-glenn20.readthedocs ... spnow.htmlspecifically the https://micropython-glenn20.readthedocs ... iving-datapart. For an example go here:
https://github.com/davefes/ESP-Now-repe ... water_tank and look at the repeater code.
Have fun!
Re: ESP-Now support for ESP32 (and ESP8266)
Ah - as suggested by Dave, the firmware-esp32-GENERIC.bin file should be the right one for your device. The M5STACK_ATOM image is compatible though - it just includes some extra pre-configured code for the M5Stack board. I recommend using the GENERIC image though so you can be sure.
Yes - two way communication is possible. I use it all the time. Remember that on each device you have to use add_peer() to add the MAC address of the other device before you can send it a message (see https://micropython-glenn20.readthedocs ... w.add_peer).I still have a little question though, I do have oneway communication now, is twoway also possible?
Example: One board asks and the other answers.
Re: ESP-Now support for ESP32 (and ESP8266)
Good evening,
(Here in Belgium it's evening and hot at the moment
)
Thx for your help Dave and Glenn most of the things are working find now.
I did try the Generic first but it didn't work at that moment. Now it does (I might have a faulty board in my pile).
The only problem I'm having at this moment is: when I boot the little board, and it loads the program with the espnow in it, it crashes.
Is this a normal thing at this moment?
Greetings Luc
(Here in Belgium it's evening and hot at the moment
![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
Thx for your help Dave and Glenn most of the things are working find now.
I did try the Generic first but it didn't work at that moment. Now it does (I might have a faulty board in my pile).
The only problem I'm having at this moment is: when I boot the little board, and it loads the program with the espnow in it, it crashes.
Is this a normal thing at this moment?
Greetings Luc
Re: ESP-Now support for ESP32 (and ESP8266)
No.
Paste the minimum code that causes the problem. I suggest that you leave boot.py as is and in main.py just import my_program.py
Also a utime.sleep(5) at the beginning of my_program.py gives you a chance to break into the program before it starts running.
Paste the minimum code that causes the problem. I suggest that you leave boot.py as is and in main.py just import my_program.py
Also a utime.sleep(5) at the beginning of my_program.py gives you a chance to break into the program before it starts running.