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 » Thu May 19, 2022 9:41 am

Lucje wrote:
Wed May 18, 2022 5:34 pm
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?
I am going to guess that when you say "crash", you mean that the esp32 reboots with something like the message "Guru mediation error" :-).
While it is possible that is a software problem or a glitch that can be worked around, it is also true that sometimes this can happen when your power supply does not provide enough power for the esp32. When you turn on the radio it can use a lot more power (it is still small compared to mobile phones, but it uses a lot more power with the radio on - especially when the radio first turns on.

I don't know that is your problem - but I have had this problem in the past when I was using one particular power supply that was enough to support the esp32 with the radio off, but when it turned on - the spike in current was too much for my anemic little power supply and the board would reboot.

So, before investing a time in chasing possible software problems check it with a beefier power supply.

User avatar
Lucje
Posts: 17
Joined: Sat May 14, 2022 4:08 pm
Location: Belgium

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

Post by Lucje » Thu May 19, 2022 9:56 am

glenn20 wrote:
Thu May 19, 2022 9:41 am
Lucje wrote:
Wed May 18, 2022 5:34 pm
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?
I am going to guess that when you say "crash", you mean that the esp32 reboots with something like the message "Guru mediation error" :-).
While it is possible that is a software problem or a glitch that can be worked around, it is also true that sometimes this can happen when your power supply does not provide enough power for the esp32. When you turn on the radio it can use a lot more power (it is still small compared to mobile phones, but it uses a lot more power with the radio on - especially when the radio first turns on.

I don't know that is your problem - but I have had this problem in the past when I was using one particular power supply that was enough to support the esp32 with the radio off, but when it turned on - the spike in current was too much for my anemic little power supply and the board would reboot.

So, before investing a time in chasing possible software problems check it with a beefier power supply.
Sorry I'm not always clear in my questions (I always have this problem). I will do my best to avoid this.

If I plug the ESP into my pc and connect (and the EspNow things are loaded with it), it crashes and I have to re-burn the firmware.

I'm going to study the power problem and keep you informed of the result.
Thank you for your reply.
Greetings Lucje

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 » Thu May 19, 2022 10:12 am

If I plug the ESP into my pc and connect (and the EspNow things are loaded with it), it crashes and I have to re-burn the firmware.
If you have a standard Micropython v1.18 image on the ESP32 and plug it into your PC and run a simple program it runs OK?

I have never used
uPyCraft V1.1
are you following something like this https://randomnerdtutorials.com/flash-u ... 2-esp8266/?

I would expect a PC USB port to be able to handle an ESP32. I had situations when using a ESP8266 with having to re-load the firmware. I think the programs were just too big, moving to an ESP32 and that problem disappeared.

User avatar
Lucje
Posts: 17
Joined: Sat May 14, 2022 4:08 pm
Location: Belgium

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

Post by Lucje » Thu May 19, 2022 10:23 am

davef wrote:
Thu May 19, 2022 10:12 am
If I plug the ESP into my pc and connect (and the EspNow things are loaded with it), it crashes and I have to re-burn the firmware.
If you have a standard Micropython v1.18 image on the ESP32 and plug it into your PC and run a simple program it runs OK?

I have never used
uPyCraft V1.1
are you following something like this https://randomnerdtutorials.com/flash-u ... 2-esp8266/?

I would expect a PC USB port to be able to handle an ESP32. I had situations when using a ESP8266 with having to re-load the firmware. I think the programs were just too big, moving to an ESP32 and that problem disappeared.
It runs ok when start it without the EspNow. Both firmware's (the standard and the Generic for the EspNow)

When I load it fresh to the board and start the script, it goes fine.
But it's not a good think to have to plug in the pc to make it work :D
And it's is Esp32, it should be strong enough...

User avatar
Lucje
Posts: 17
Joined: Sat May 14, 2022 4:08 pm
Location: Belgium

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

Post by Lucje » Thu May 19, 2022 10:31 am

In the meantime I have looked at the power problem. Even with an extra power supply the problem is still there.
Assume that it must really go wrong during boot.

This is my boot script:

Code: Select all

import esp
import os
files=os.listdir()
if len(files)>=2:
    print('The device have %d files'%int(len(files)-1))
    for i in range(len(files)):
        if files[i]!='boot.py':
          print('file name:',files[i])
          try:
              exec(open(files[i]).read(),globals()) #Here the other .py files get loaded.
              print('Ok!')
          except:
              print("Syntax error!")
            
else:
    print("MicroPython has no files!")

It always has worked except now.

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 » Thu May 19, 2022 10:45 am

It runs ok when start it without the EspNow. Both firmware's (the standard and the Generic for the EspNow)
By "without the ESPNow" do you mean when not doing

Code: Select all

from esp import espnow
When I load it fresh to the board and start the script, it goes fine.
But it's not a good think to have to plug in the pc to make it work :D
And it's is Esp32, it should be strong enough...
Does your IDE actually download the files on to the ESP32 or run them from the IDE?

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 » Thu May 19, 2022 10:46 am

Are you hitting the EN button after you have downloaded the files and removed the USB connection?

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 » Thu May 19, 2022 10:57 am

I would not run a program like that in boot.py.

Leave boot.py with nothing in it.
In main.py

Code: Select all

import my_program
in my_program.py put your wanted program.

Putting that code in boot.py and something goes wrong I am pretty certain that you will not be told what happened.

User avatar
Lucje
Posts: 17
Joined: Sat May 14, 2022 4:08 pm
Location: Belgium

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

Post by Lucje » Sat May 21, 2022 9:51 am

davef wrote:
Thu May 19, 2022 10:46 am
Are you hitting the EN button after you have downloaded the files and removed the USB connection?
When it runs, I can pull the USB out and it keeps running (on battery power), as long I don't reboot or reset.
.

User avatar
Lucje
Posts: 17
Joined: Sat May 14, 2022 4:08 pm
Location: Belgium

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

Post by Lucje » Sat May 21, 2022 10:42 am

davef wrote:
Thu May 19, 2022 10:45 am
It runs ok when start it without the EspNow. Both firmware's (the standard and the Generic for the EspNow)
By "without the ESPNow" do you mean when not doing

Code: Select all

from esp import espnow
No, I mean loading MyProgram.py where I use code for EspNow.
When I load it fresh to the board and start the script, it goes fine.
But it's not a good think to have to plug in the pc to make it work :D
And it's is Esp32, it should be strong enough...
Does your IDE actually download the files on to the ESP32 or run them from the IDE?
Yes it does. I't wouldn't work when I pull the USB while still it keeps running on the battery. (12V battery (12LS.1.2) converted to 5V)

Post Reply