Zigbee supporting Esp32 module with Arduino

I posted the edited section of the code which is an exact duplicate from the portion I linked to in that reply also... so hopefully they will spot the difference(s) that matter.

@snell

some new user has a new comment here:

He says that he has success without any mod to the file on repo...

There are some slight differences between the new example that is linked and the old example... but none of them stood out to me as being a way to make it work, but maybe they are.

The one posted a couple weeks ago from Greginkansas seems much more useful.

@snell

which one ?
this: ?

but it is IDF not arduino.
Did you try it ? any success ?

@snell

I changed my hub from Hubitat C8 to C7 and now I am able to pair with esp32-c6 with the code from:

arduino-esp32/libraries/ESP32/examples/Zigbee/Zigbee_Light_Bulb at master Ā· espressif/arduino-esp32 Ā· GitHub

My hub detects it as a generic light switch. But the on/off commands do nothing.
The code does not provide any logs, so I don't know what really is happening.
any ideas ?

btw, the Arduino example seems to at least pair so it is not that bad.
the problem was with my C8 hub as discussed here:

I spent some time yesterday getting my Arduino IDE updated and updated my ESP32 Board Package to the latest DEV build. This was required to support my ESP32-C6-DevKitC-1 microcontroller.

After doing so, I was able to compile the example Arduino Zigbee Light Bulb sketch.

Unfortunately, I could not get the device to pair via Zigbee with either my C8-Pro or C7 hubs. Nor could I get it to pair with Zigbee2MQTT on Home Assistant. I went to sleep last night feeling a little disappointed.

This morning, I pulled out my 2018 Hubitat C-3 Hub and powered it up. I was able to successfully pair the ESP32-C6 via Zigbee with the C-3 hub! WooHoo! However, it did not pair as a Zigbee Switch or Light device. So, I changed the driver type to "Device" and then clicked Remove State, Remove Attributes, etc... I wanted to make sure the device was as clean as possible, and then I changed the driver to "Generic Zigbee Switch", clicked Save, and then clicked Configure. Afterwards, I was able to use the ON and OFF commands successfully. The LED changes immediately, however the status updates appear to take ~2 seconds before Hubitat 'sees' the switch attribute change.

So, it is a start. Feels like the example sketch needs some work to properly perform the necessary handshakes with modern Zigbee controllers. Also, the device is not reporting its capabilities properly during the pairing process.

I am hopeful that someone will get this sorted out so that these ESP32-C6 and ESP32-H2 devices can be used via Zigbee with modern Zigbee controllers.

2 Likes

@ogiewon
I am surprised that it does not pair with your C7 hub.
Which code did you use ?
I tried this one , and it successfully pairs with my C7:

Pairing is successful but can not control (turn on/off)
I tried the method you used (set as device, remove states, set as generic zigbee switch)
I was able to control it once. But other than that I can't control it.
It just seems to be in pairing mode always. If I try adding the device to hub while it was already defined, it shows up pairing as the already added device.

Same code as you linked above is what I used.

well then it is weird. isn't it ?
We have the same hub (C7)
but with the same device and code we have different outcome:
you can't even pair.
I can pair but can't control.
on the other hand, you can pair and control with another hub (C3)

Do you enable the following line when flashing the code ?
//esp_zb_nvram_erase_at_start(true); //Comment out this line to erase NVRAM data if you are conneting to new Coordinator

Yes, I have tried using with and without that line commented out. I also made sure to erase everything via the Arduino IDE when flashing the microcontroller.

On both the C8-Pro and C7, it gets stuck in the INITIALIZING phase of pairing.

Just to add my 2 centsā€¦ I would like to build some sensors as well, and got a ESP32-C6. I can confirm what you have discovered. On my C8 hub it begins to initialize:

As soon as HE starts the initialization however, the ESP32 responds with ā€œLeaveā€ and then ā€œFailed to Initialize zigbee stackā€:

I was able to pair the ESP32 to a ST hub:

And a Tuya hub:

well that's really interesting.
On my C8 it gets stuck at initializing but on my C7 it pairs well.
So we have a problem with Hubitat hubs. Since it pairs with Tuya and ST...

1 Like

Does anyone know, if there are any supported zigbee modules that can pair with the C8?

Are you talking about modules that work through Arduino? There are obviously modules that do otherwise no ZigBee devices would work with it at all.

Plus, the fact that I had gotten my ESP32-C6 to pair (and work) with my C8 and now my C8-Pro means it does work. I just could not get it to work with the Arduino sample. I had to use the Espressif IDF sample instead.

To be honest, at this point I am not worrying so much about it and focusing more on what I can do over WiFi for my projects than ZigBee.

1 Like

I havenā€™t tried it with a C8 or C8-Proā€¦ but possibly the following Zigbee module would work. Not sure if this is the type of Zigbee module youā€™re looking for?

I have one of those. Seems to work fine (including on my C8 - at least last time I tried it, which admittedly has been quite a while).

He has a battery powered version too, but I haven't tried that one.

Battery version:

1 Like

ok. back to the subject.
I'd really appreciae if anyone can write here when some example arduino code really works with esp32-c6 and Hubitat.

I am going to try to get this working on a C7 with ESP-IDF and Arduino later.

To be candid, once you have the IDF extension set up in Visual Studio Code, itā€™s a superior IDE than Arduino (just like PlaformIO in VS is better for Arduino dev than the Arduino IDE).

And as far I understand the IDF platform while more complex is better suited for iot development than the more simplistic. The former is the more native, real time platform for ESP32 dev. Arduino platform which oversimplifies the ESP32 platform and possibilities by offering that simpler but more restrictive setup loop.

Though for very simple device control, you might not care.

1 Like

nice to see someone else is also interested :slight_smile:

I really don't care about the platform we develop. Since I have Arduino ready on my PC, I prefer using it. But installing ESP-IDF shouldn't be so difficult.
I'm just waiting to see a really successful example. Successful on any hub (not just Hubitat C3)
Besides, the examples now we have only include a switch and a bulb. And there is no good documentation for making a sensor for example...

1 Like

Full disclosure: I'm new to the ESP32 boards, but have successfully created some sensors. I'm now trying to integrate the one or another into Hubitat. I have a few of the C6 DevKits and would like to use them if possible.

What are you using that works? I purchased a Freenove kit with S3 WROOM (no Zigbee) first, and they suggested Thonny for Python or the Ardurino IDE for C. I got a C6 DevKit from WaveShare that recommended VS Code (I've been using VS -not code- for years for C#) and a C6 DevKit from DIYMall