Zigbee supporting Esp32 module with Arduino

so you didn't install VS or Eclipse.
Just installed python and the idf executables for building ?

Just used the "Standard Setup" using the Offline Installer. So I have the IDE installed... but I did not use it for this "simple" part.

BTW, in my opinion the on/off light does not perform very well. It frequently does not respond to on/off commands for a period of time. Sometimes it "catches up" and sometimes it just sits and I have to try again. USUALLY once it responds to something it works better for a while... but even that is not always the case.

@snell

thanks for the feedback.
I would start with IDF but since you say it is neither working fine, I will keep working on Arduino.

I'd appreciate if you could support me on :

@snell , @ogiewon
Can you please support me here:

Still not seeing how the changes you've made to this post have anything to do with the OP's question. I agree with @ilkeraktuna, your question deserves its own thread. Although, I seem to recall you having asked this same Zigbee/Thermocouple question many times over the past many months... :thinking:

If @ilkeraktuna is successful in getting an ESP32 to run Zigbee Home Automation, and connecting to Hubitat, then there might be an option in the future to build off of that work to have a Thermocouple attached to an ESP32 talking Zigbee. Until that time, let's please keep this thread on topic. Thank you.

1 Like

Ok, I get it now.

So this effort is to get an ESP32 to run zigbee directly, without Arduino?

Please correct me, but it seems like this was already done.

I'm still shocked that I can't buy a thermocouple zigbee/z-wave sensor off the shelf. All I ever get is: build one yourself with ESPxx, arduino, or whatever, which I can't/won't do.

Sorry for distracting.

As the author of HubDuino, I can assure you that HubDuino/ST_Anything does not support using Zigbee as a communications protocol with an ESP32 module that is natively capable of running Zigbee.

HubDuino/ST_Anything does support the very old SmartThings Zigbee ThingShield, which basically allowed an Arduino UNO or MEGA board to communicate via a Zigbee radio. That board is very obsolete, and I have not had anyone mention it for years now. HubDuino these days only supports WiFi/Ethernet connected devices.

3 Likes

Thanks for the explanation.

The hope here is to be able to use an ESP32-C6 or H2 (or future boards with ZigBee support) to pair directly to the Hubitat and communicate with it, being programmed using the Arduino IDE (and all it offers).

To summarize the current state (as of 1/28/2024) of what has been accomplished by forum members:

  1. An ESP32-C6 CAN be paired with a Hubitat using firmware based on the Espressif On/Off Light ZigBee example. However, the example needs substantial changes to the main ZigBee task function within it (otherwise it will not pair) AND it only works from the Espressif IDF (and presumably IDE) NOT from the Arduino IDE.
  2. Attempts to "port" it to the Arduino IDE have not been successful.
  3. The Arduino examples provided (as a fork, not in the mainline Espressif github) DO NOT pair with Hubitat and have not been able to be made to work.
  4. Questions to a couple sections of the github have not received answers that have proven useful:
    a) Asking about updating the Arduino examples to make them work with a "normal" controller basically came back as "ask in the main ZigBee" area... while the area for the question was the one that included the examples. Link
    b) Asking in the main ZigBee section got limited responses to date that basically say "it works with zigbee2mqtt so it would be your hub (Hubitat) that is the problem" (and ignored the question about why the logging does not work properly that was also asked). Link
4 Likes

@snell

I got this answer:

To answer about the part of the Arduino support of Zigbee.
If you have any ESP-IDF example you can run it within Arduino just with small changes. We didn't created any wrapper library on top of the Zigbee SDK, we are just providing the libs, so they can be used in Arduino. Those 2 examples are just a slightly edited Zigbee SDK example, to not rely on other esp-idf libraries that we don't have available in Arduino.
So if you have sources to the examples, that worked with ESP-IDF and the Habitat, please share them and I am sure with not much effort they can be used within Arduino.

so , could you please share the IDF code that works for you on the thread:

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.