I have an existing ZigBee network running and in Home Assistant and I’m using Zigbee2MQTT
I have several (off the shelf) devices connected to the ZigBee network and everything is working great.
I now want to develop my own device using a ESP32-C6 in the Arduino IDE, using the Arduino Framework.
I’ve got the demo applications for a switch and light working and talking to each other, but those examples don’t show code for Zigbee discovery mode to join an existing network (I.e the HomeAssistant network).
So my question is this.
Has any one got the ESP32-C6 running with Zigbee (either as a EndDevice or Router Device) using the Arduino Framework where you have manage to network to the Home Assistant Zigbee network, and you’re using that device in Home Assistant.
For some background I would like to create a fish pond controller that controls several 240V and 12V pumps/bulbers, also receive temperatures, water levels, etc.
I have this pond controller working already using 433Mhz with a Arduino Nano, but wanted to port it over to Zigbee using ESP32-C6. I know I could port it over to ESP32 with WiFI and have a restFUL API but the purpose of this project was to play with Zigbee. However I’m stuck at the first point as I can’t even see my devices in Zigbee2MQTT discovery.
Any pointers and better still example code (above the espressif example code) would be awesome.
Were you able to make any progress on this? I am currently in the process of doing the same thing, porting an ESP32 wifi device over to Zigbee ESP32-C6. I was able to get the program to run but stuck at the concept of getting the device to join existing Zigbee network.
I’m going to join this discussion because I have several devices I want to recreate as zigbee devices. I have two little xiao esp32c6’s and have set one up as their example light control.
I got it to join with Z2M on the third or fourth try after fixing stupid mistakes along the way. All I had to do was enable joining and then plug the board into a usb c cable. Z2M saw it after a few seconds and it joined. It was given one of the 0x… names and I played with the switch a bit, lighting the little LED on the board.
It isn’t right though, there seems to be some problems in the code, because thing work only through the callback, not through the ‘loop’ construct in the code.
However, I wanted to let these folk know that I DID get it to join.
I was able to get some of the ESP32 sample projects connecting to my HA Z2M setup.
Things I noticed:
You may have to update the channel and mask in the code to match your network.
The ESP32 didn’t have great range on the internal antenna. You can use an external antenna but IIRC you also need to enable it with a code change. I simple moved my ESP as close as I could to a router.
One thing that puzzled me was how to get the ESP to report to HA/Z2M without having to make a custom device. Once I made a custom device added the external antenna it worked fine.
I didn’t go much further with the ESP as I could never get the power consumption low enough to have a decent battery life.
It would be nice if there was a Z2M developer guide for this kind of thing.
Adam (The video creator) does a really good job of demo’ing ESP32C6 connecting to a Zigbee network.
I was originally having all sorts of connection issues, but Adam help me. Turned out my problem was firmware related in my Sonoff USB v3 adapter. Once I updated to the latest firmware my ESP32C6 connected straight away.
The ESP32 is connected to my HA, and in HA I can toggle the light entity and the LED on the device does indeed toggle on and off.
Happy days…
However I have found a limitation in the Zigbee Arduino Library.
If I press the button on the device to toggle the LED it doesn’t tell HA that the status of the light has changed. Unlike other zigbee endpoints (E.g. temperature) the setTemperature() followed with reportTemperature() reports back the temp to HA.
However there doesn’t seem to be a reportLight() function.
After some google searching I found this function call.
esp_zb_zcl_set_attribute_val(
10, // your endpoint
ESP_ZB_ZCL_CLUSTER_ID_ON_OFF,
ESP_ZB_ZCL_CLUSTER_SERVER_ROLE,
ESP_ZB_ZCL_ATTR_ON_OFF_ON_OFF_ID,
&onBoardLED, // pointer the bool for the LED
true // trigger report (but it doesn't)
);
But all this does is set the attribute locally on the ESP32 and doesn’t report it back.
So my question is this…
Any ideas how I can get the ESP32 to report back to HA via Z2M that the LED has changed status following a local button press?