ESP-NOW & WIFI - Performance and Channel

kwijibo007
Posts: 1
Joined: Mon Oct 21, 2019 1:59 am

ESP-NOW & WIFI - Performance and Channel

Postby kwijibo007 » Mon Oct 21, 2019 2:46 am

I'm using ESP-Now to send data very quickly (in the millisecond range) from an ESP32 based sensor ("the master") to another ESP32 that drives a bunch of LEDs ("the slave"). It works amazingly well.

I'm now experementing with concurrently connecting "the master" ESP32 to Wi-fi in order to interact with it. There is no requirement to also have "the slave" connected to Wi-fi. For now I have hard coded the ESP-Now channel to match my Wi-fi AP's channel. The only way I can find to set the channel on "the slave" is to either create a softAP or also connect it to Wi-fi (which I have no need for), any attempt to send data via ESP-Now (with Wi-fi connected) silently fails without doing this. Without Wi-fi, I can send ESP-Now data on any channel without setting it on "the slave". All I do is esp_wifi_start() & esp_now_init().

I can send ESP-Now data when connected to Wi-fi (when "the slave" is softAP or connected to my AP) but performance is extremely poor. I have no way to quantify it except that without Wi-fi, there is no noticeable latency, with Wi-fi there is huge latency. Range is also greatly affected. Without Wi-fi ESP-Now works through several walls from one end of a house to another. With Wi-fi no data is received greater than 3 meters in the same room. I do not believe my issues are due to a congested channel. Without connecting to Wi-fi I can use the same channel without negative effect.

Is it known/expected that concurrent Wi-fi and ESP-Now has a performance/range hit? I suspect I'm only seeing this issue due to my data rate requirements.

Is there a way to force "the slave" to listen on a particular channel without creating a softAP or connecting it to the same Wi-fi? In my testing (and searching) esp_wifi_set_channel() does not work on "the slave" without a SoftAP. Why is it that it doesn't work when "the master" is connected to wifi but does when not (and using the exact same channel)?.

Thanks,

Pete

jc9999
Posts: 2
Joined: Wed Nov 20, 2019 9:09 am

Re: ESP-NOW & WIFI - Performance and Channel

Postby jc9999 » Wed Nov 20, 2019 9:18 am

Hi,
I have a very similar problem.

Situation:
- 2 x esp32
- same channel (6)
- payload size: 15 bytes
- broadcasting.
- 1 msg every 20 millisec.
- mode STA

While not connected to any Wifi network ( wifi.disconnect() ) ESPNow is working very well, less than 0.1% of packet are lost.

Once one of the esp32 is connected to a wifi router on the channel 6, performance is very bad. more than 80% of packets are lost.
This is not the channel problem since some messages are ok when connected, and it work well when not connected.

I am using the arduino framework for the WiFi lib, but I believe this is related with espnow itself...

Can this be fixed, or espnow is not meant to be efficient while connected to a wifi network ?

Thank you for any advise,
JC.

jc9999
Posts: 2
Joined: Wed Nov 20, 2019 9:09 am

Re: ESP-NOW & WIFI - Performance and Channel

Postby jc9999 » Wed Nov 20, 2019 7:37 pm

Answering myself with what I found on google and tested.
adding this

Code: Select all

esp_wifi_set_ps(WIFI_PS_NONE);
solved my poor transfer quality in STA mode connected to my wifi.

Switching to AP_STA also works.

zhangyanjiao
Posts: 24
Joined: Mon Aug 28, 2017 3:27 am

Re: ESP-NOW & WIFI - Performance and Channel

Postby zhangyanjiao » Thu Nov 21, 2019 11:48 am

jc9999 wrote:
Wed Nov 20, 2019 7:37 pm
Answering myself with what I found on google and tested.
adding this

Code: Select all

esp_wifi_set_ps(WIFI_PS_NONE);
solved my poor transfer quality in STA mode connected to my wifi.

Switching to AP_STA also works.
Yes, you are right. When ESP32 has connected to a router, you need to close the MODEM_SLEEP, otherwise it will affect the performance of the ESP-NOW.

zhangyanjiao
Posts: 24
Joined: Mon Aug 28, 2017 3:27 am

Re: ESP-NOW & WIFI - Performance and Channel

Postby zhangyanjiao » Thu Nov 21, 2019 12:00 pm

Hi kwijibo007,
Is there a way to force "the slave" to listen on a particular channel without creating a softAP or connecting it to the same Wi-fi? In my testing (and searching) esp_wifi_set_channel() does not work on "the slave" without a SoftAP. Why is it that it doesn't work when "the master" is connected to wifi but does when not (and using the exact same channel)?.
Currently, you can only call esp_wifi_set_channel() after wifi initialized and sniffer enabled. We are trying to modify this function to let it can set the channel as long as the wifi initialized, thus you can set the channel in STA mode. But we will still don't support setting channel when the STA has connected to an AP, or when STA is scanning, or STA is connecting to an AP.

zhangyanjiao
Posts: 24
Joined: Mon Aug 28, 2017 3:27 am

Re: ESP-NOW & WIFI - Performance and Channel

Postby zhangyanjiao » Tue Jan 07, 2020 1:06 pm

Hi kwijibo007,
The esp_wifi_set_channel() API has been updated in IDF master branch https://github.com/espressif/esp-idf/co ... 2440ed82ef.

Who is online

Users browsing this forum: No registered users and 26 guests