-
Notifications
You must be signed in to change notification settings - Fork 7.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESP-NOW does not workig with WiFi (STA) mode (IDFGH-8924) #10341
Comments
Have you tried to disable modem sleep, i.e.
|
hi @rajneeshsinha. have you tried the ESP-NOW example, and could you please provide some error log |
@kriegste Thanks for suggestion. I have tried with your suggestion to put the MCU in NO POWER SAVING mode but it didn't work. Attached image for your reference, So, if I comment the WiFi_connect then esp-now works. Following is the wifi_connect function does: `void wifi_connect(char *ssid, char *pass)
}` Do you have any other suggestion that need to try? Did you try at your side with this same requirement application and it works? Let me know if you need any other details from my end? I am suspecting, running ESP32 in station mode (to get internet access from router) + ESP-NOW broadcaster/receiver mode is not feasible at the movement till that we have proper solution or any work around works here. |
Did you do this, too?
|
same issue here, once esp_wifi_connect(); is called, esp now does not work |
Congratudolences, guys! This core functionality has been broken for at least a year! |
hi @goatzillax this issue is fixed in IDF 5.0 and later version. if you want tou use it on 4.3/4.4, you should init esp-now first ,then connect to AP, and the esp-now can send packet normally. and we will backport to 4.4 |
@Xiehanxin I wonder if there is some sort of miscommunication here. I'm on 2.0.14 of the ESP32 package which apparently is IDF 4.4 (correct me if I'm wrong). I just tried moving esp_now_init before connecting the RX to an AP, and it still fails. My testcase is otherwise the same. I press the button, it disconnects, and then the ESP-NOW messages start showing up. So as far as I can tell, moving esp_now_init before WiFi.begin() is not a workaround for IDF 4.4. I've updated my testcase. https://github.com/goatzillax/espnow_crosstest Can you show me the testcase you used to verify functionality? |
@goatzillax I noticed that your ESPNOW packets are broadcast packets. When STA is connected to wifi, it will only receive the broadcast packet whose bssid is equal to the associated AP bssid. Therefore, packet receiving fails. Suggest you use unicast to send. |
My comment says, "// broadcast works, unicast does not if RX is connected to an AP". I have the broadcast address as a placeholder in my repo. I do not believe you understand this bug or my code. Unicast to an RX connected to a STA, even when all devices are on the same channel, does not work. The last I checked, Espressif's test cases do not test this specific scenario. It's claimed to be fixed in 5.0 but given the total situation I highly doubt it. |
@goatzillax In this https://github.com/goatzillax/espnow_crosstest testcase, I don't see the |
I am almost certain that requirement was removed in the ESP32 version of the libraries. I tried to make that painfully clear in the file naming -- the receiver is an ESP32-C3 and the transmitter is an ESP8266, and their libraries are not the same although they should be able to communicate with each other over ESP-NOW. Again, I don't think you understand the bug, testcase, and now the API. The testcase boots up with the RX in STA mode. No messages are received. When I press the button, it disconnects from STA and goes into SoftAP mode, and messages are then received. All without having called esp_now_add_peer. This is why I suspect espressif's own testcase aren't being run. I don't think they'll even compile due to API changes. |
Just checked the docs, it does not indicate that esp_now_add_peer is required to receive messages. In fact I don't think that was ever a requirement as I'm looking back at some old code. It was the master/slave notion they did away with. |
Sorry, I made a mistake, it's not required to add peer when receiving. |
I will test the case on Arduino. By the way, can you please have a try on Arduino 3.0.0 (which is based on IDF v5.1)? |
Hello all, here there is a working code, it have both transmitter and receiver, running on the ESP32, to set the module as WIFI_STATION and connect to an AP, must be configured as: As the ESP-Now IDF said: it must be set as the channel that station or softap is on. The transmitter have a search channel routine to find the receiver channel, Tested on a ESP32-C3 (revision v0.4). Note: Enjoy coding ! Jose Luis |
@rajneeshsinha @goatzillax do you still have this problem? |
I tried the esp_wifi_set_promiscuous workaround that PepeTux mentioned, but that did not work for me. I don't know what you mean by Arduino 3.0.0. Do you mean the arduino-esp32 3.0.0 board package? I tried that version, and it is still broken in the exact same way. I have not seen a test case in any suite that indicates anybody actually understands the bug in the first place. No test case == not fixed |
I have the same issue, once esp_wifi_connect() is called, esp now stops to work. |
Yes, I mean the arduino-esp32 3.0.0 board package. |
@leonardodanelutti can you provide a demo to test? |
Sorry @zhangyanjiaoesp, I am using Rust in my project, but I am doing the same things as @rajneeshsinha and @goatzillax on IDF 5.1:
At this point, ESP-NOW stops working if the AP's channel is not 1. The problem seems to be that ESP-NOW and the Wi-Fi must be on the same channel, but it is impossible to set a channel other than 1 on the ESP-NOW transmitter (error: peer channel is not equal to home channel, send fail!). |
I thought @Xiehanxin confirmed this fixed in IDF 5.1 in Dec 2023. I asked for the testcase back then because it's hard to imagine how a fix can be confirmed without a testcase. I also provided my own testcase. It's literally sitting in its own repo. The TX side is coded for ESP8266 but you can obviously change that to work on an ESP32 if necessary. You just need two devices. Seems like this should be part of an automated suite. Now, if you guys have your own testcase for this, great, I wouldn't mind reviewing it. Again, kind of hard to say this is fixed without a testcase. |
@leonardodanelutti When the STA connects to AP, it will change it's home channel same to the AP. For example, the default channel for STA is channel 1, when STA connects to a channel 5 AP, the STA will change the home channel to 5. So if the home channel of your STA and AP is different, you need to call |
@goatzillax I have tested your code on Arduino 3.0.0, and I didn't reproduce your issue. And on Arduino 2.0.14, I can reproduce the issue, so I create a PR espressif/esp32-arduino-lib-builder#165 to fix it, but the config can't be changed, so suggest to use Arduino 3.0.0. |
That's interesting. The TX side just sends a message whenever reset is pressed so it's pretty simple. So when you ran the RX code, you connected it to a STA, then while still connected to the STA (confirmed with a ping from another machine), you pressed reset on the TX device and saw it blink the LED and/or watched the serial port output and it confirmed "msg received"? |
@zhangyanjiaoesp I know that, but as I said for me it is impossible to change the channel of the peer in the ESP-NOW transmitting device. As soon as I call |
@leonardodanelutti The |
yes |
@zhangyanjiaoesp the error message is displayed when I call |
@zhangyanjiaoesp seem that this should be fixed on 5.2, I will test that |
@leonardodanelutti I know the log displayed when call |
Huh. One last thing -- did you change the TX to transmit to a specific MAC (I.e. make it use unicast)? I only put the broadcast in as a placeholder. |
yes, I have changed it to my communicate device MAC |
OK. Well, all I can do is leave this here. I updated my testcase to make it slightly harder to mess up; all you have to do is set your SSID/password and channel in the RX code. I literally made a video of what I'm seeing: https://www.youtube.com/watch?v=dEBRfFWL9lQ When the code starts up, it connects to an AP and no ESP-NOW messages are received. I press the button, it disconnects, and it starts receiving messages. The serial console text from the video:
Can you point out where in your test suite this exact functionality is actually tested? |
Answers checklist.
General issue report
Hello
I am working on ESP-IDF release version-4.4 and having requirements to put the ESP32 device on APSTA mode mean, device should work in AP mode (start web page) and in STA mode connect to router to get internet access. With these both mode device work correctly but after initializing ESP-NOW it doesn't works (Rx data call back handler never called).
I have tried following things before posting this issue here:
I already checked following links:
Any suggestions will be appreciated.
The text was updated successfully, but these errors were encountered: