ESP-Now support for ESP32 (and ESP8266)
-
- Posts: 4
- Joined: Thu Jul 21, 2022 1:10 pm
-
- Posts: 4
- Joined: Thu Jul 21, 2022 1:10 pm
Re: ESP-Now support for ESP32 (and ESP8266)
I also double checked this image:
https://github.com/glenn20/micropython- ... ENERIC.bin
BTW:
I fixed the
to
https://github.com/glenn20/micropython- ... ENERIC.bin
BTW:
I fixed the
Code: Select all
from esp import espnow
Code: Select all
import espnow
Re: ESP-Now support for ESP32 (and ESP8266)
Right. However, before you changed it you should have got another error message.
Last edited by davef on Fri Jul 22, 2022 9:42 am, edited 1 time in total.
Re: ESP-Now support for ESP32 (and ESP8266)
e0 singleton parameters
In the docs I see that the e0 singleton uses irecv to store data:
Thanks,
Dave
In the docs I see that the e0 singleton uses irecv to store data:
Does that mean you can keep dumping in e0 traffic until you run out of RAM? Or how many bytearrays and how big?ESPNow.irecv([timeout])¶
Works like ESPNow.recv() but will re-use internal bytearrays to store the return values: [mac, peer], so that no new memory is allocated on each call.
Thanks,
Dave
Re: ESP-Now support for ESP32 (and ESP8266)
A quick look at your code and I can see that:Rocket2022 wrote: ↑Thu Jul 21, 2022 1:17 pmI'm trying to get esp_now running and created a controller class to handle the esp_now stuff.
When I try to sent a simple data string, I've got an internal error (Error: (-12394, 'ESP_ERR_ESPNOW_INTERNAL')).
I'm using the "firmware-esp32-GENERIC.bin" image.
Has someone an idea what can be wrong?
self.wlan.active() should be self.wlan.active(True).
However, I'm not sure that will be the cause of your problem. If you continue to get an espnow internal error, you might try hard resetting the device, eg. Power cycle it.
Good luck.
-
- Posts: 4
- Joined: Thu Jul 21, 2022 1:10 pm
Re: ESP-Now support for ESP32 (and ESP8266)
Hi Glenn,
thanks you are right. I forgot the True value...
Now it's working properly.
Marco
thanks you are right. I forgot the True value...
Now it's working properly.
BRself.wlan.active() should be self.wlan.active(True).
Marco
Re: ESP-Now support for ESP32 (and ESP8266)
Thats a good question Dave.davef wrote: ↑Thu Jul 21, 2022 7:52 pme0 singleton parameters
In the docs I see that the e0 singleton uses irecv to store data:Does that mean you can keep dumping in e0 traffic until you run out of RAM? Or how many bytearrays and how big?ESPNow.irecv([timeout])¶
Works like ESPNow.recv() but will re-use internal bytearrays to store the return values: [mac, peer], so that no new memory is allocated on each call.
TLDR; e.config(rxbuf=xxxx) might be what you are looking for if you want to increase the buffering of incoming espnow messages .
All incoming espnow messages are saved in an internal buffer which is about 530 bytes in size by default. Thats big enough for two full sized messages (250 bytes) plus some overhead for packet headers.
If the buffer fills up, any new messages will be silently dropped (although you can see if messages are being dropped on an esp32 by looking at the data returned by ESPNow.stats()). You can change the size of the buffer using ESPNow.config(rxbuf=2048) before calling active(True).
So, messages will always be saved (up to the limit of the buffer size) until you can read them out of the buffer with recv(), irecv() or recvinto().
recv() allocates a new bytes object for every new message that is received and copies the new message out of the buffer into the bytes object. If you are dealing with a lot of espnow traffic the performance of your app can be impacted by the garbage collection processes triggered by all those memory allocations and can lead to greater memory fragmentation. So, I added irecv() which allocates one bytearray and reuses that for every incoming message.
If you print(id(e.irecv()[1])) for every message you will see that the same memory is used for every incoming message. If you replace irecv() with recv() you will see that new memory is used for every message.
You can see how irecv() works by looking at https://github.com/glenn20/micropython/ ... /espnow.py
Re: ESP-Now support for ESP32 (and ESP8266)
I hadn't "connected" rx_buffer size with irecv() but now see it is really a high-level configuration for all recv functions. Thank you.
Yesterday, I realised that you have a esp32_generic_spiram image. One day I will try that out on a spare SPIRAM variant.
Yesterday, I realised that you have a esp32_generic_spiram image. One day I will try that out on a spare SPIRAM variant.
Re: ESP-Now support for ESP32 (and ESP8266)
Can't get the complete repeater link system working with v1.19.1
Three units:
- a remote
- a repeater
- a local
All units have v1.191.1 on them and I have the repeater talking to the local, but the remote doesn't talk to the repeater.
Local w0 channel 6
Repeater w0 channel 6
Remote w0 channel 6
On the remote ...
Tried channel 1 at the remote and leaving the w0 assignment off ... neither worked.
Is this the time you set different channels on the e0 interface just so the remote can talk to the repeater?
Thanks,
Dave
Three units:
- a remote
- a repeater
- a local
All units have v1.191.1 on them and I have the repeater talking to the local, but the remote doesn't talk to the repeater.
Local w0 channel 6
Repeater w0 channel 6
Remote w0 channel 6
On the remote ...
Code: Select all
w0 = network.WLAN(network.STA_IF)
w0.active(True)
print (w0.config('mac'))
w0.config(channel=6)
print (w0.config('channel'))
e0 = espnow.ESPNow()
# print (e0)
e0.active(True)
Is this the time you set different channels on the e0 interface just so the remote can talk to the repeater?
Thanks,
Dave
Re: ESP-Now support for ESP32 (and ESP8266)
@davef - a few questions:
- are these all esp32 devices?
- does e0.send() on the remote return False or True?
- is the repeater connected to wifi?
- if so, what does w0.config("ps_mode") on the repeater return?
A few things to try:
- after you call e0.add_peer() on the remote, check that e0.get_peers() returns the expected values for the remote (esp. that the channel is 0).
Try sending a message from the repeater to the remote and see if it receives the message.
- are these all esp32 devices?
- does e0.send() on the remote return False or True?
- is the repeater connected to wifi?
- if so, what does w0.config("ps_mode") on the repeater return?
A few things to try:
- after you call e0.add_peer() on the remote, check that e0.get_peers() returns the expected values for the remote (esp. that the channel is 0).
Try sending a message from the repeater to the remote and see if it receives the message.