-
Notifications
You must be signed in to change notification settings - Fork 31
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
Zigbee ZHA support with Arduino - ESP32-C6 (TZ-595) #228
Comments
Its the hub the code joins to my setup with zigbee2mqtt just fine. |
there is no zigbee2mqtt in my setup. And I did not understand the relevance of your answer with my question. I have a Hubitat hub which is acting as a zigbee coordinator. |
The relevance is that it can connect to another system. So I would take a look at your zigbee coordinator, also as part of your trouble shooting. |
you don't understand. Besides , you are not connecting to a zigbee hub as I require. I am waiting support from the project owners... |
Whether the Hubitat hub is well known or not is not really relevant. What i expect zigbee2mqtt to do is, and @Greginkansas correct me if i am wrong, it will add the device anyways but will mark it as unsupported. Meaning it is not able to bind the signature to any distinct actions. As for your hubitat, it might be that it just does not know the zigbee device signature and straight up rejects it. |
@TheKayneGame In my experience with Esp32-c6 Arduino examples the device can not complete pairing. On the other hand other people had success with Espressif IDF examples slightly modifying them. I am still looking for Espressif developers' help. We need proper examples for pairing to a hub. |
@ilker-aktuna To answer about the part of the Arduino support of Zigbee. Question about the logs: Did you set the debug at least to error? To get all logs select in the Arduino IDE Tools menu -> Debug Level -> Verbose. |
I replaced the esp_zb_task with the below code (from within issue 10662's thread). This allowed it to work with the Hubitat when the ESP32-C6 was flashed using the IDF.
|
@P-R-O-C-H-Y |
I have 2 zigbee running now 1 on the garage door now running for 4 days with no crashes and 1 with get this a lux senser using a Adafruit driver. So this one both sends and receives commands. /**
#ifndef ZIGBEE_MODE_ED #include "esp_zigbee_core.h" #include "Wire.h" float LUX_READ; #define LED_PIN RGB_BUILTIN /* Default End Device config */ #define ESP_ZB_DEFAULT_RADIO_CONFIG() /* Zigbee configuration / /********************* Zigbee functions **************************/ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct) static esp_err_t zb_action_handler(esp_zb_core_action_callback_id_t callback_id, const void *message) char modelid[] = {13, 'E', 'S', 'P', '3', '2', 'C', '6', '.', 'L', 'i', 'g', 'h', 't'}; static void esp_zb_task(void *pvParameters)
///////////////////////// Start illuminance_measurement
// esp_zb_attribute_list_t *esp_zb_illuminance_measurement_cluster = esp_zb_zcl_attr_list_create(ESP_ZB_ZCL_ATTR_ILLUMINANCE_MEASUREMENT_MEASURED_VALUE_DEFAULT);
///esp_zb_cluster_list_add_illuminance_meas_cluster(esp_zb_cluster_list, esp_zb_illuminance_measurement_cluster, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); esp_zb_cluster_list_add_temperature_meas_cluster(esp_zb_cluster_list, esp_zb_temperature_meas_cluster, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE); // esp_zb_cluster_list_update_basic_cluster(esp_zb_cluster_list, esp_zb_basic_cluster_create(NULL), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);
} /* Handle the light attribute */ static esp_err_t zb_attribute_handler(const esp_zb_zcl_set_attr_value_message_t *message)
} { LUX_READ = veml.readLux(); esp_zb_zcl_status_t state_tmp = esp_zb_zcl_set_attribute_val(HA_ESP_LIGHT_ENDPOINT, ESP_ZB_ZCL_CLUSTER_ID_TEMP_MEASUREMENT, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_TEMP_MEASUREMENT_VALUE_ID, &temperature , false); //er /* Check for error */
} /********************* Arduino functions **************************/ xTaskCreate(update_lux, "update_lux_value", 4096, NULL, 2, NULL); void loop() { |
@Greginkansas |
I tried @P-R-O-C-H-Y's example last night with success, but I downloaded it from a different link. I used an ESP32-C6-DevKitC. After a reset, the DevKit was recognised by ZHA. I use a Zigbee 3.0 USB Dongle Plus (ZBDongle-E EFR32MG21) with Multiprotocol firmware as coordinator. The Silicon Labs Multiprotocol Add-on forwards the ZigBee communication to ZHA. |
@mitag |
To be honest, I don't remember if my other ZigBee devices automatically triggered pairing, as I set up Home Assisstant several times a year ago, first twice on Raspberrys and finally on an Intel Mini PC. When I set up the Bosch Smart Home Radiator Thermostats II last autumn, manual work was necessary. That's why I didn't notice yesterday that I had to call up ZHA and initiate pairing from there. I'm sorry that this didn't seem worth mentioning. Addendum: I have not changed anything in Zigbee_Light_Bulb.ino. |
so your experience is not relevant to what I'm trying to achieve ? |
I'm sorry, I've probably written too much again. Only the following statements are relevant: Have you tried to initiate the pairing from ZHA? |
I'm trying to achieve something similar with the ESP32-H2. If I load in this Zigbee_Light_Bulb.ino does the ESP automatically enter pairing after flashing? So would all I need to do is set the coordinator to pairing mode and it should connect? What's the device recognized as? |
@superzanti |
Zigbee_Light_Bulb.ino is not able to initiate pairing on its own, you have to initiate it from the coordinator. This worked for me, as I described above. The pairing went perfectly, I was then able to switch the LED on and off and the status of the LED was also transmitted correctly by Zigbee_Light_Bulb.ino. I used an ESP32-C6, but it should work just as well with the ESP32-H2. |
@mitag Generally when pairing a device, I have tos et my coordinator in pairing mode AND the device in pairing mode. I can initiate from the coordinator no problem (using the zigbee2mqtt interface). So I'm assuming, if yours pairs perfectly after initiating from the coordinator, your ESP is either already paired to the coordinator (by manually setting some configs when flashing) or it flashes and starts in pairing mode. Can you clarify your setup? |
What I do know is that after flashing or resetting the ESP-C6, it is ready to perform a pairing initiated by the coordinator. I flash Zigbee_Light_Bulb.ino without making any changes to it and I don't have to set any parameters anywhere, just let the coordinator search for new devices. After resetting the ESP-C6 again, the pairing remains in place. If I delete the ESP-C6 in the coordinator, the pairing only works again after a reset of the ESP-C6. As the example code refers to the importance of selecting the Partitio scheme (Zigbee 4MB with spiffs), I assume that the data transmitted by the coordinator during pairing is saved by one of the integrated libraries in the spiffs in order to survive a reset. `
*/ ` I selected the following in the Arduino IDE, in Tools, because it seemed logical to me. The pairing is performed here:
` |
@mitag thanks. |
If the end device was never connected to the coordinator, just restarting the ESP by reset button can help. If it was already connected to some coordinator and you want to create new connection, you need to erase flash memory (it may also help to erase it for the first time to be sure, that the zigbee partition will be also clear). You can check the Readme of the example, all is written there: If the End device flashed with this example is not connecting to the coordinator, erase the flash before flashing it to the board. It is recommended to do this if you did changes to the coordinator. You can do one of the following:
|
I changed my hub from Hubitat C8 to C7 and now I am able to pair with esp32-c6 with the code from: My hub detects it as a generic light switch. But the on/off commands do nothing. |
Check the logs on your Hubidat. |
but why doesn't these log_i , log_w lines work ? log_i("Start network steering"); log_w("Failed to initialize Zigbee stack (status: %s)", esp_err_to_name(err_status)); log_i("Joined network successfully (Extended PAN ID: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x, PAN ID: 0x%04hx, Channel:%d, Short Address: 0x%04hx)", |
You need to set Debug Level in Arduino IDE - Tools menu to "Verbose" or "Info" to see those in serial monitor. |
Debugs seem to work after I set it on IDE and restart. With the example code , currently this is what happens with Hubitat hubs: On C8 hub it gets stuck at "initializing" phase I really want this to work. But I'm not sure how to troubleshoot. |
FYI, you will get those same type of pairing/joning issues (including device interviewing failing or not completing) if you either have sources of EMF/EMI/RMI interference too close to the Zigbee devices (especially close to the Zigbee Coordinator and closest Zigbee Router) or similar problem symptoms you do not have enough "known good" Zigbee Router devices as well as also similar problem symptoms when having bad Zigbee Router devices that do not pass along all communication messages. See example: Anyway, regardless of your enviroment and Zigbee gateway solution you are using, before troubleshooting any first, be aware that with all Zigbee setups you first be sure to always actively take some basic but important preventive actions to avoid EMF/EMI/RMI interference by using a long USB 2.0 extension cable (or USB 3.0 extension cable to a USB 2.0 port/hub) as well as adding known good Zigbee Router devices. If possible try to follow all the tips in these hardware-independent best practise guides:
Another tips; for easier troubleshooting from the Zigbee gateway side can I suggest that you buy one CC2652P based Zigbee Coordinator radio adapter dongle (like example the "Sonoff ZBDongle-P" by ITead), + flash that with the latest latest community Z-Stack Zigbee Coordinator (NCP) firmware build from Koenkk's master branch, and then install the latest version of Zigbee2MQTT to test with that as Zigbee Coordinator USB dongle? -> https://www.zigbee2mqtt.io Zigbee2MQTT has a great community for troubleshooting (and developing of) third-party devices from the Zigbee gateway side: Optionally, for some chaos engineering you could also buy the Home Assistant's SkyConnect USB stick and test with Home Assistant's ZHA integration as at least those should rule out of the problem is only with one Zigbee gateway solution or with all. |
@Hedda |
With Zigbee it can be the other way around if the devices do not just follow the most basic device function using Zigbee Home Automation profile specification, so much will depend on the device handling done on the Zigbee Gateway side, and depending on their implementation the Zigbee Gateway developers may need to make some custom changes to support new devices. Thus you get different results with different Zigbee Gateway software implementations.
While they do not cover all sample scenarios, check out the recently added additional examples, see https://github.com/espressif/esp-zigbee-sdk/tree/main/examples/esp_zigbee_HA_sample and https://github.com/espressif/esp-zigbee-sdk/tree/main/examples/ |
ok thank you. I'll try these. But really we have to understand what's missing that causes my hub not pair with this device... |
are there Arduino versions of these ? |
Example: https://github.com/espressif/arduino-esp32/tree/master/libraries/ESP32/examples/Zigbee/Zigbee_Light_Bulb i try join in SLS and z2m and I didn't succeed, the announcement comes and that's it, the device does not respond to interview requests
I have a suspicion that this is a problem with Install Code, although in the example install_code_policy = false |
Zigbee examples in the arduino-esp32 repository should be syncronized and updated to work with latest esp-zigbee-sdk, see: https://github.com/espressif/arduino-esp32/tree/master/libraries/ESP32/examples/Zigbee Also, Espressif released "stable" version 3.0.0 Arduino ESP32 Core based on ESP-IDF v5.1.4 with support for ESP32-H2 / ESP32-C6: https://github.com/espressif/arduino-esp32/releases/tag/3.0.0 (Arduino ESP32 core v3.0.0 was first announced over 7-month ago but this updated version is now finally been marked as stable). As well means from now can report upstream problems or feature requests related to ESP32-H2/ESP32-C6 as new issues here: https://github.com/espressif/arduino-esp32/issues/ PS: Espressif has still not created a Arduino wrapper library on top of the Zigbee SDK, they are however at least providing libraries: |
Closing, please file separate issues if anything else need to follow up for this topic. |
FYI, looks like a Zigbee API/wrapper for Arduino on ESP32 (arduino-esp32) is being working on very activly right now and initial (basic) Zigbee library support has been merged into both |
Question
I am trying to make a working zigbee end device using a ESP32-C6 Dev module and Arduino IDE.
I found the Arduino example from here:
https://github.com/P-R-O-C-H-Y/arduino-esp32/blob/Zigbee-examples/libraries/ESP32/examples/Zigbee/Zigbee_Light_Bulb/Zigbee_Light_Bulb.ino
But this did not try to join any network.
So I changed the "esp_zb_task" method with:
with this change , the device is trying a join on my hub. (Hubitat)
I can see the device being detected on hub but it is stuck at "initializing" phase.
I'm not sure why , log_i and log_e statements in the example code do not produce on serial monitor.
So I added some serial.println replacing them. These work and I see that the ESP_ZB_BDB_SIGNAL_STEERING is received , but I get these errors i after that:
Network steering was not successful (status: ESP_FAIL
ZDO signal: ZDO Device Unavailable
So what is missing in this code to join a hub ?
Also, why doesn't the log_i and log_e statements work for me ?
Additional context.
No response
The text was updated successfully, but these errors were encountered: