Skip to content
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

ESP32-C6 Zigbee and wifi AP and STA error #10871

Open
1 task done
sonirohit3 opened this issue Jan 16, 2025 · 14 comments
Open
1 task done

ESP32-C6 Zigbee and wifi AP and STA error #10871

sonirohit3 opened this issue Jan 16, 2025 · 14 comments
Assignees
Labels
Area: WiFi Issue related to WiFi Area: Zigbee Issues and Feature Request about Zigbee Status: Awaiting triage Issue is waiting for triage

Comments

@sonirohit3
Copy link

Board

ESP32-C6

Device Description

Esp32-c6 custom board

Hardware Configuration

ESP32-C6 custom board

Version

latest master (checkout manually)

IDE Name

Arduino

Operating System

Macos

Flash frequency

40

PSRAM enabled

yes

Upload speed

115200

Description

Wifi doesn't work in STA or AP more when Zigbee is initialized. Also I don't see a way to de-init zigbee.
Idea is to use Wifi OTA activated with a switch.
-> When using AP mode, the client can find the AP but cannot connect.
-> When using STA mode, the WiFi won't connect and return error:

Sketch

STA code:

  WiFi.mode(WIFI_MODE_AP);
  if (!WiFi.softAP(ssid, password)) 
  {
    log_e("Soft AP creation failed.");
  }
  IPAddress IP = WiFi.softAPIP();
  Serial.print("AP IP address: ");
  Serial.println(IP);



STA code:

WiFi.mode(WIFI_OFF);
  delay(100);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  delay(5000);
  while (WiFi.waitForConnectResult() != WL_CONNECTED) {
    WiFi.begin(ssid, password);
    log_i("WiFi failed, retrying.");
  }

Debug Message

Debug logs for STA mode

[ 20549][V][STA.cpp:110] _onStaArduinoEvent(): Arduino STA Event: 110 - STA_START
[ 22960][V][STA.cpp:216] _onStaEvent(): STA Disconnected: SSID: Soni_wifi2G_IOT, BSSID: 00:00:00:00:00:00, Reason: 201
[ 22961][V][NetworkEvents.cpp:113] _checkForEvent(): Network Event: 113 - STA_DISCONNECTED
[ 22962][V][STA.cpp:110] _onStaArduinoEvent(): Arduino STA Event: 113 - STA_DISCONNECTED
[ 22962][W][STA.cpp:137] _onStaArduinoEvent(): Reason: 201 - NO_AP_FOUND
[ 22963][D][STA.cpp:155] _onStaArduinoEvent(): WiFi Reconnect Running
[ 22963][W][STA.cpp:541] disconnect(): STA already disconnected.
[ 25370][V][STA.cpp:216] _onStaEvent(): STA Disconnected: SSID: Soni_wifi2G_IOT, BSSID: 00:00:00:00:00:00, Reason: 201
[ 25371][V][NetworkEvents.cpp:113] _checkForEvent(): Network Event: 113 - STA_DISCONNECTED
[ 25371][V][STA.cpp:110] _onStaArduinoEvent(): Arduino STA Event: 113 - STA_DISCONNECTED
[ 25372][W][STA.cpp:137] _onStaArduinoEvent(): Reason: 201 - NO_AP_FOUND
[ 25372][D][STA.cpp:158] _onStaArduinoEvent(): WiFi AutoReconnect Running
[ 25373][W][STA.cpp:541] disconnect(): STA already disconnected.
E (29754) wifi:sta is connecting, return error
[ 25566][E][STA.cpp:417] connect(): STA connect failed! 0x3007: ESP_ERR_WIFI_CONN
[ 25567][I][Handle_OTA.ino:37] init_wifiAP(): WiFi failed, retrying.
E (29766) wifi:sta is connecting, return error

Other Steps to Reproduce

Init Zigbee and then init the wifi.

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@sonirohit3 sonirohit3 added the Status: Awaiting triage Issue is waiting for triage label Jan 16, 2025
@me-no-dev
Copy link
Member

please provide full sketch code to reproduce the issue

@lbernstone
Copy link
Contributor

Try adding this to your code:

#include <esp_coexist.h>
void setup() {
    esp_coex_wifi_i154_enable(void)

@sonirohit3
Copy link
Author

sonirohit3 commented Jan 17, 2025

Hi @lbernstone , Your suggestion worked for STA mode. Still the problem persists in AP mode. The AP is created but the client such as mobile is not able to connect. Any insight on that?

@P-R-O-C-H-Y
Copy link
Member

Just a quick note: Since there is only one RF path in ESP32-C6, which means Wi-Fi and Zigbee can't receive simultaneously, it has a significant impact on performance. Hence the two SoCs solution is recommended.

@P-R-O-C-H-Y P-R-O-C-H-Y added Area: WiFi Issue related to WiFi Area: Zigbee Issues and Feature Request about Zigbee labels Jan 17, 2025
@P-R-O-C-H-Y P-R-O-C-H-Y self-assigned this Jan 17, 2025
@lbernstone
Copy link
Contributor

Hi @lbernstone , Your suggestion worked for STA mode. Still the problem persists in AP mode. The AP is created but the client such as mobile is not able to connect. Any insight on that?

The SSID is not visible, or negotiation problems? Post a log.

@sonirohit3
Copy link
Author

Hi @lbernstone & @P-R-O-C-H-Y , The SSID is visible in mobile but the connection is always getting failed. Unfortunately there are no logs when client tries to connect. I do understand that RF path is single. If I can disable Zigbee ( like Zigbee.disable()) and init a WiFi AP mode, this will solve my purpose.
Here is the code snippet:

setup:

void setup()
{
Serial.begin(115200);
log_i("Booting up...");
esp_coex_wifi_i154_enable();
init_pheripherals();
init_Zigbee();
init_flash();
digitalWrite(PCA_OE, LOW);

}

Init_ota function which is called with longpress of switch:

void OTA_init()
{
is_ota_en=1;
WiFi.mode(WIFI_MODE_AP);
if (!WiFi.softAP(ssid, password))
{
log_e("Soft AP creation failed.");
}
IPAddress IP = WiFi.softAPIP();
Serial.print("AP IP address: ");
Serial.println(IP);

OTA_server_init(); // simple AP based webserver
}

Below are logs for same:

[ 48363][V][NetworkEvents.cpp:113] _checkForEvent(): Network Event: 101 - WIFI_READY
[ 48372][V][AP.cpp:108] _onApEvent(): AP Started
[ 48373][V][NetworkEvents.cpp:113] _checkForEvent(): Network Event: 130 - AP_START
[ 48373][V][AP.cpp:88] _onApArduinoEvent(): Arduino AP Event: 130 - AP_START
[ 48376][V][AP.cpp:112] _onApEvent(): AP Stopped
[ 48377][V][NetworkEvents.cpp:113] _checkForEvent(): Network Event: 131 - AP_STOP
[ 48377][V][AP.cpp:88] _onApArduinoEvent(): Arduino AP Event: 131 - AP_STOP
[ 48669][V][AP.cpp:108] _onApEvent(): AP Started
[ 48670][V][NetworkEvents.cpp:113] _checkForEvent(): Network Event: 130 - AP_START
[ 49184][I][Handle_Zigbee.ino:59] Update_devstate_server(): Updating Endpoint : 11 with value : 0
[ 49185][I][Handle_Zigbee.ino:59] Update_devstate_server(): Updating Endpoint : 12 with value : 0
[ 49186][I][Handle_Zigbee.ino:59] Update_devstate_server(): Updating Endpoint : 13 with value : 1
[ 49187][I][Handle_Zigbee.ino:59] Update_devstate_server(): Updating Endpoint : 14 with value : 0
[ 49188][I][Handle_Zigbee.ino:59] Update_devstate_server(): Updating Endpoint : 15 with value : 1
[ 49189][I][Handle_Zigbee.ino:69] Update_devstate_server(): Updating Temperature Endpoint : 16 with value : 0
[ 49190][V][ZigbeeTempSensor.cpp:58] setTemperature(): Updating temperature sensor value...
[ 49190][D][ZigbeeTempSensor.cpp:60] setTemperature(): Setting temperature to 0
[ 57066][V][ZigbeeCore.cpp:352] esp_zb_app_signal_handler(): ZDO signal: NLME Status Indication (0x32), status: ESP_OK
[ 59217][I][Handle_Zigbee.ino:59] Update_devstate_server(): Updating Endpoint : 10 with value : 0
[ 59218][I][Handle_Zigbee.ino:59] Update_devstate_server(): Updating Endpoint : 11 with value : 0
[ 59219][I][Handle_Zigbee.ino:59] Update_devstate_server(): Updating Endpoint : 12 with value : 0
[ 59220][I][Handle_Zigbee.ino:59] Update_devstate_server(): Updating Endpoint : 13 with value : 1
[ 59221][I][Handle_Zigbee.ino:59] Update_devstate_server(): Updating Endpoint : 14 with value : 0
[ 59222][I][Handle_Zigbee.ino:59] Update_devstate_server(): Updating Endpoint : 15 with value : 1
[ 59223][I][Handle_Zigbee.ino:69] Update_devstate_server(): Updating Temperature Endpoint : 16 with value : 0
[ 59224][V][ZigbeeTempSensor.cpp:58] setTemperature(): Updating temperature sensor value...
[ 59224][D][ZigbeeTempSensor.cpp:60] setTemperature(): Setting temperature to 0

@TD-er
Copy link
Contributor

TD-er commented Jan 18, 2025

I don't know enough about Zigbee, but I wonder what channels it needs.
Is there some overlap in frequencies?
If so, maybe you could try to force the AP to use a channel which is overlapping with the Zigbee frequency?

For STA mode, you do have 'idle' time inbetween beacons.
However when using AP mode, you have not.
That's also why you absolutely need to use the same channel for STA and AP in AP+STA mode, or else your connection is as stable as a drunk on rollerskates.

So I guess the problem here is the constant frequency hopping.

I found this online:

Image

So maybe you could use WiFi channel 1 along with Zigbee channel 12 or 13?
And perhaps you can limit your WiFi AP mode to 802.11g as this is smaller than the 20 MHz width as depicted by the blue area in the image.

If Zigbee does use frequency hopping, like Bluetooth does, then it sounds to me like a lost cause as it is technically hardly usable.

@sonirohit3
Copy link
Author

@TD-er , So in this case only way to tackle this issue is to disable Zigbee when AP for firmware update has to be init. Better to have Zigbee.disable function.

@P-R-O-C-H-Y , Can you suggest if we have this functionality?

@P-R-O-C-H-Y
Copy link
Member

@sonirohit3 I was searching through all available APIs of esp-zigbee-sdk and I didn't see any option to disable/deinit Zigbee.

@sonirohit3
Copy link
Author

@P-R-O-C-H-Y , I agree. I also looked on this and found this missing. Any workaround you can suggest?

@P-R-O-C-H-Y
Copy link
Member

@sonirohit3 I asked the Zigbee team if there is any way. I was also curious about the C5 as it have 5 GHz WiFi.
I forced the WiFi to be 5GHz only and I when Zigbee was also running I was not able to connect to the AP.
When I have any news, I will let you know.

@TD-er
Copy link
Contributor

TD-er commented Jan 27, 2025

@P-R-O-C-H-Y
Does the C5 allow the 2.4 and 5 GHz WiFi to be active at the same time?
I guess if it does, then it will draw significant amounts of energy, especially when both are in AP mode.
Just based on the video Andreas Spiess made about the C5, it looks like both bands share the same antenna feed, so I doubt both can be active at the same time.
Image

If you can do 5 GHz WiFi + some 2.4 GHz activity (Zigbee/BT/WiFi), then I guess it will only be in STA mode for WiFi and not in AP mode. (so also not STA+AP)
In AP mode the antenna is continuously occupied, so it cannot be used for something else.

A simple test for this hypothesis is to use Bluetooth and WiFi AP mode at the same time.
I suspect that if it is even supported, it will be extremely unstable.

@P-R-O-C-H-Y
Copy link
Member

@TD-er You can check some coexistence info here in the IDF docs for C6 https://docs.espressif.com/projects/esp-idf/en/stable/esp32c6/api-guides/coexist.html

I asked for Zigbee/WiFi to be added, as I saw many users asking about this in other repositories also.

About the C5, I just got it for few days now, did not test many things, was just curious about the AP on 5GHz + Zigbee.
Also the C5 support is still in a preview in IDF master, so there might be updates to this also.

@TD-er
Copy link
Contributor

TD-er commented Jan 27, 2025

I am a bit surprised to see the ESP-NOW TX with BLE coexistance to be "Y" and not "S".
ESP-NOW can be used on the STA interface and on the AP interface.
Typically for nodes that need to receive data from other nodes, you want to run ESP-NOW on the AP interface as that's always listening (unless it is sending of course).

So I would expect it to be "C1" (unstable) when running ESP-NOW in AP mode and "S"/"Y" for ESP-NOW TX in STA mode.

Any (future) table showing the coexistance between Thread and WiFi will likely be all "S" or "C1" and probably some "X" values in both the column and row for 'scan'.

Like I mentioned before, in STA mode you do have some time between the beacons, which can also be increased by setting the DTIM to a higher value to favour stability and response time for the other (BLE or Thread) over WiFi.
In AP mode you don't have such 'gaps'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: WiFi Issue related to WiFi Area: Zigbee Issues and Feature Request about Zigbee Status: Awaiting triage Issue is waiting for triage
Projects
None yet
Development

No branches or pull requests

5 participants