Zigbee supporting Esp32 module with Arduino

I purchased a couple of the ESP32-C6-DevKitC-1-N8 Development Boards off Amazon a while ago (checked my order history and found the listing but no longer available).

As for the code, I put a link to what I used further up in this thread (post 20, UPDATE 3). With a specific sample of it in post 23. I also had to update the libraries that the IDF was using.

@ilkeraktuna , just to be clear, the difference is vast between the Arduino platform (either in its Arduino IDE form or in VS Code with PlatformIO) and ESP-IDF (command line or in VS Code via the ESP-IDF extension). It's not about the IDE or toolchain but is a completely different approach to controller programming.

Where Arduino with its setup/loop approach makes it easy to start with, EDP-IDF is much more complex but offers more in-depth control targeting professional developers and advanced hobbyists who need full features of the ESP32 chips, looking to build real-time applications.

I am just starting now with IDF, having used Arduino prior.

1 Like

Thank you! That really is a big help! I've probably messed up my PC with all the different programs and libraries and such :man_facepalming:, So I need to get rid of it all first and start over (in a VM :wink:).

1 Like

Yeah... I know the Arduino IDE is maybe not the best out there anymore but I am used to it. I also still do most of my 3D generation (printing or graphics) using "code style" engines not graphics-editing tool ones... Heck, I still use Notepad++ for a lot of my code work.

So I am probably not the best example for what IDE to use for something.

I'm a proponent of using the best tool that I have for a particular job. I have no brand loyalty.

As another test, I spent some time installing the Espressif IDF Extension for VS Code on Windows 11. I was able to install the latest IDF v5.2 on my system. I then made sure I could build and flash my ESP32-C6 with the Blink example. All good.

Next, I set up to try and replicate @snell's success using the Espressif IDF with the aforementioned modified code changes. I incorporated the changes, and was then able to build the example Zigbee code. I flashed it to my ESP32-C6 and then attempted to pair it my my C8-Pro, C7, and C3 hubs. Once again, only the C3 was successful. I will say that the device was discovered much more correctly, as a Generic Zigbee Outlet, and the On/Off commands worked properly. Status updates were consistently quick. So, definitely better, but still having trouble pairing with the C7 and C8 hubs for me.

I just received an ESP32-H2 that I will continue testing with later this week.

2 Likes

really your C8 , C7 and C3 experience VS my C7 , C8 experience is different and I am worried about that.

To summarize:
You: (both Arduino and IDF)
C3 : success , pair and control
C7: not pairing
C8-pro: not pairing

Me: (only Arduino so far)
C7: pairing success, control fails
C8: not pairing

I just tried with the ESP32-H2. I get the exact same results using it versus the ESP32-C6.

the problem is not hw, it is the code...

Yes, I realize that. But sometimes code runs differently on different hardware. Thus the test.

there are new example codes here:

So just for the hell of it I did as search on esp32 modules the other day and after a little bit of reading just learned about the zigbee enabled versions. Hell I didn’t even know there were wifi6 versions.

I then learned about the limited support for zigbee in the arduino ide and via some more googling a Hubitat forums link that I totally missed somehow.

I use notepad++ for an editor but do all my building in the arduino ide. I have platform IO installed and want to move to it but evidently my current project isn’t written properly enough for platform IO.

I am still knee deep in my current project using just a plain-jane esp32 wroom dev board so I am not diving into this right now, but I really appreciate all the info given here.

1 Like

@snell

I finally moved to ESP-IDF environment. Compiled the light on off example with modifications you added.
Hubitat hub can see it as pairing but after initial pairing it does not control.
If I change the device type to Generic Zigbee Bulb and re-pair it (when it is already paired) , hub finds and reconnects. After this phase I can control with on off functions.
However after some time , it stops receiving commands.
Once it stops receiving commands, if I start pairing again, I can control it.

Seems like the device does not complete pairing on its side. And it starts fail logs:

I (831696) ESP_ZB_ON_OFF_LIGHT: Received message: endpoint(10), cluster(0x6), attribute(0x0), data size(1)
I (831696) ESP_ZB_ON_OFF_LIGHT: Light sets to Off
I (831776) ESP_ZB_ON_OFF_LIGHT: Received message: endpoint(10), cluster(0x6), attribute(0x0), data size(1)
I (831776) ESP_ZB_ON_OFF_LIGHT: Light sets to On
I (831786) ESP_ZB_ON_OFF_LIGHT: Received message: endpoint(10), cluster(0x6), attribute(0x0), data size(1)
I (831786) ESP_ZB_ON_OFF_LIGHT: Light sets to Off
I (832826) ESP_ZB_ON_OFF_LIGHT: Received message: endpoint(10), cluster(0x6), attribute(0x0), data size(1)
I (832826) ESP_ZB_ON_OFF_LIGHT: Light sets to On
I (848516) ESP_ZB_ON_OFF_LIGHT: ZDO signal: ZDO Leave (0x3), status: ESP_OK
I (848516) ESP_ZB_ON_OFF_LIGHT: Network steering was not successful (status: ESP_FAIL)
I (851936) ESP_ZB_ON_OFF_LIGHT: Network steering was not successful (status: ESP_FAIL)
I (877826) ESP_ZB_ON_OFF_LIGHT: ZDO signal: ZDO Leave (0x3), status: ESP_OK
I (877826) ESP_ZB_ON_OFF_LIGHT: Network steering was not successful (status: ESP_FAIL)
I (881246) ESP_ZB_ON_OFF_LIGHT: Network steering was not successful (status: ESP_FAIL)

2 Likes

@snell

At first, I could not find a solution to the "pair , success , fail , re-pair, success, fail , re-pair" loop.
Then I gave up and tried to introduce a level and color setting feature to make it a dimmable color light bulb.
Added level and color clusters (esp_zb_level_cluster_add_attr , esp_zb_color_control_cluster_add_attr)

Then my initial problem (pair, success, fail , re-pair) was solved all of a sudden.
I don't know what caused the problem and how it was resolved.

Now level setting works, but color setting does not work.

The example of dimmable color bulb I found has color mode and capability set as:

color_mode = 0x0002; // ColorTemperatureMireds

color_capabilities = 0x0010; // Color temperature supported

And on Hubitat , I use the Generic Zigbee RGB Light profile.
Maybe these mode and capability setting is not compatible.
But I don't know what other values can be set.

Any ideas ?

What is the color mode and capability used by internal Hubitat driver ?

I have not been using the RGB or dimming, just on/off. The driver I selected was the "Generic ZigBee Outlet" only allowing for on/off.

Interestingly enough, despite not updating the code on it in quite some time OR even using it on the Hubitat, I just tried the on/off when I was looking up the device to answer and it worked just fine. It has been powered all this time.

So the basic capability I got going on it is still working.

OK. On top of that I added level control and now working on color control.
If I only could find color mode and color capability settings...

Can I find the driver code for Generic Zigbee RGB Light Bulb on Hubiat ?

Not sure, but this might help you.

3 Likes

thanks. it is helpful but I still could not find the values for color mode and color capabilities

Sorry if this isn’t relevant, but maybe something in here can help…

1 Like

thanks. that is actually relevant. But I need to learn what color capability setting I need to do on the ESP side to get hue and saturation commands from the Hubitat driver.
I can't find that information anywhere..