Zigbee supporting Esp32 module with Arduino

Actually Espressif IDE codes can be easily ported to Arduino as far as I understand.

Check these 2 codes:

One is the pure Espressif IDE version, the other is the Arduino.

@snell
good news :slight_smile:
Can you share what you changed to make the example (espressif IDE one) work on a hub ?

btw, the esp32-c6 has an inner RGB led which we can try to control as a color lamp to test.
it is defined as:
#define LED_PIN RGB_BUILTIN

and then controlled as:
neopixelWrite(LED_PIN,255light_state,255light_state,255*light_state);

in this example:

Sure. The idf_component.yml is small enough, that changed to (you can see the old versions it listed commented out):

## IDF Component Manager Manifest File
dependencies:
  espressif/led_strip: "^2.5.2"
  espressif/esp-zboss-lib: "~1.0.9"
  espressif/esp-zigbee-lib: "~1.0.9"
  #espressif/esp-zboss-lib: "~1.0.0"
  #espressif/esp-zigbee-lib: "~1.0.0"
  #espressif/led_strip: "~2.0.0"
  ## Required IDF version
  idf:
    version: ">=5.0.0"

The esp_zb_light.c file, I replaced the esp_zb_task portion with what was posted in issue 10662 I linked before. Here is what I used:

char modelid[] = {13, 'E', 'S', 'P', '3', '2', 'C', '6', '.', 'L', 'i', 'g', 'h', 't'};
char manufname[] = {9, 'E', 's', 'p', 'r', 'e', 's', 's', 'i', 'f'};

static void esp_zb_task(void *pvParameters)
{
    // initialize Zigbee stack with Zigbee end-device config 
    esp_zb_cfg_t zb_nwk_cfg = ESP_ZB_ZED_CONFIG();
    esp_zb_init(&zb_nwk_cfg);
    esp_zb_set_primary_network_channel_set(ESP_ZB_PRIMARY_CHANNEL_MASK);

    // set the on-off light device config
    uint8_t test_attr, test_attr2;
 
    test_attr = 0;
    test_attr2 = 4;
    // basic cluster create with fully customized
    esp_zb_attribute_list_t *esp_zb_basic_cluster = esp_zb_zcl_attr_list_create(ESP_ZB_ZCL_CLUSTER_ID_BASIC);
    esp_zb_basic_cluster_add_attr(esp_zb_basic_cluster, ESP_ZB_ZCL_ATTR_BASIC_ZCL_VERSION_ID, &test_attr);
    esp_zb_basic_cluster_add_attr(esp_zb_basic_cluster, ESP_ZB_ZCL_ATTR_BASIC_POWER_SOURCE_ID, &test_attr2);
    esp_zb_cluster_update_attr(esp_zb_basic_cluster, ESP_ZB_ZCL_ATTR_BASIC_ZCL_VERSION_ID, &test_attr2);
    esp_zb_basic_cluster_add_attr(esp_zb_basic_cluster, ESP_ZB_ZCL_ATTR_BASIC_MODEL_IDENTIFIER_ID, &modelid[0]);
    esp_zb_basic_cluster_add_attr(esp_zb_basic_cluster, ESP_ZB_ZCL_ATTR_BASIC_MANUFACTURER_NAME_ID, &manufname[0]);
    // identify cluster create with fully customized
    esp_zb_attribute_list_t *esp_zb_identify_cluster = esp_zb_zcl_attr_list_create(ESP_ZB_ZCL_CLUSTER_ID_IDENTIFY);
    esp_zb_identify_cluster_add_attr(esp_zb_identify_cluster, ESP_ZB_ZCL_ATTR_IDENTIFY_IDENTIFY_TIME_ID, &test_attr);
    // group cluster create with fully customized
    esp_zb_attribute_list_t *esp_zb_groups_cluster = esp_zb_zcl_attr_list_create(ESP_ZB_ZCL_CLUSTER_ID_GROUPS);
    esp_zb_groups_cluster_add_attr(esp_zb_groups_cluster, ESP_ZB_ZCL_ATTR_GROUPS_NAME_SUPPORT_ID, &test_attr);
    // scenes cluster create with standard cluster + customized
    esp_zb_attribute_list_t *esp_zb_scenes_cluster = esp_zb_scenes_cluster_create(NULL);
    esp_zb_cluster_update_attr(esp_zb_scenes_cluster, ESP_ZB_ZCL_ATTR_SCENES_NAME_SUPPORT_ID, &test_attr);
    // on-off cluster create with standard cluster config
    esp_zb_on_off_cluster_cfg_t on_off_cfg;
    on_off_cfg.on_off = ESP_ZB_ZCL_ON_OFF_ON_OFF_DEFAULT_VALUE;
    esp_zb_attribute_list_t *esp_zb_on_off_cluster = esp_zb_on_off_cluster_create(&on_off_cfg);
    // create cluster lists for this endpoint
    esp_zb_cluster_list_t *esp_zb_cluster_list = esp_zb_zcl_cluster_list_create();
    esp_zb_cluster_list_add_basic_cluster(esp_zb_cluster_list, esp_zb_basic_cluster, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);
    // update basic cluster in the existed cluster list
    //esp_zb_cluster_list_update_basic_cluster(esp_zb_cluster_list, esp_zb_basic_cluster_create(NULL), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);
    esp_zb_cluster_list_add_identify_cluster(esp_zb_cluster_list, esp_zb_identify_cluster, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);
    esp_zb_cluster_list_add_groups_cluster(esp_zb_cluster_list, esp_zb_groups_cluster, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);
    esp_zb_cluster_list_add_scenes_cluster(esp_zb_cluster_list, esp_zb_scenes_cluster, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);
    esp_zb_cluster_list_add_on_off_cluster(esp_zb_cluster_list, esp_zb_on_off_cluster, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);

    esp_zb_ep_list_t *esp_zb_ep_list = esp_zb_ep_list_create();
    // add created endpoint (cluster_list) to endpoint list
    esp_zb_ep_list_add_ep(esp_zb_ep_list, esp_zb_cluster_list, HA_ESP_LIGHT_ENDPOINT, ESP_ZB_AF_HA_PROFILE_ID, ESP_ZB_HA_ON_OFF_OUTPUT_DEVICE_ID);
    esp_zb_device_register(esp_zb_ep_list);
    esp_zb_core_action_handler_register(zb_action_handler);
    ESP_ERROR_CHECK(esp_zb_start(false));
    esp_zb_main_loop_iteration();
}

The color_dimmable light controls the LED if I remember correctly. That is why tonight's project will be to work on that a bit. I also had to bring over some of their "common" code and such also from github and things like that (plus getting the idf working properly) are probably what took up more time (and problem solving).

@snell

thanks for sharing that.
Unfortunately I don't have the Espressif IDE environment set up on my PC.
Is it easy to start with ?
Do you use VS or Eclipse ?

Btw, have you read my previous post about porting the code to Arduino ?
Is it possible or not ?

@snell

Adding your changes, I've changed the example Arduino code as below.
Hubitat finds the device but stays at "initializing..."
Can not complete initialize.
Also, I do not see any logs on serial.
I only see the "Starting..." log I added in the setup.



// Copyright 2023 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
 * @brief This example demonstrates simple Zigbee light bulb.
 * 
 * The example demonstrates how to use ESP Zigbee stack to create a end device light bulb.
 * The light bulb is a Zigbee end device, which is controlled by a Zigbee coordinator.
 * 
 * Proper Zigbee mode must be selected in Tools->Zigbee mode 
 * and also the correct partition scheme must be selected in Tools->Partition Scheme.
 * 
 * Please check the README.md for instructions and more detailed description.
 */

#ifndef ZIGBEE_MODE_ED
#error "Zigbee end device mode is not selected in Tools->Zigbee mode"
#endif

#include "esp_zigbee_core.h"
#include "nvs_flash.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "ha/esp_zigbee_ha_standard.h"

#define LED_PIN RGB_BUILTIN

/* Default End Device config */
#define ESP_ZB_ZED_CONFIG()                                     \
    {                                                           \
        .esp_zb_role = ESP_ZB_DEVICE_TYPE_ED,                   \
        .install_code_policy = INSTALLCODE_POLICY_ENABLE,       \
        .nwk_cfg = {                                            \
            .zed_cfg = {                                        \
                .ed_timeout = ED_AGING_TIMEOUT,                 \
                .keep_alive = ED_KEEP_ALIVE,                    \
            },                                                  \
        },                                                      \
    }

#define ESP_ZB_DEFAULT_RADIO_CONFIG()                           \
    {                                                           \
        .radio_mode = RADIO_MODE_NATIVE,                        \
    }

#define ESP_ZB_DEFAULT_HOST_CONFIG()                            \
    {                                                           \
        .host_connection_mode = HOST_CONNECTION_MODE_NONE,      \
    }

/* Zigbee configuration */
#define INSTALLCODE_POLICY_ENABLE       false    /* enable the install code policy for security */
#define ED_AGING_TIMEOUT                ESP_ZB_ED_AGING_TIMEOUT_64MIN
#define ED_KEEP_ALIVE                   3000    /* 3000 millisecond */
#define HA_ESP_LIGHT_ENDPOINT           10    /* esp light bulb device endpoint, used to process light controlling commands */
#define ESP_ZB_PRIMARY_CHANNEL_MASK     ESP_ZB_TRANSCEIVER_ALL_CHANNELS_MASK  /* Zigbee primary channel mask use in the example */


char modelid[] = {13, 'E', 'S', 'P', '3', '2', 'C', '6', '.', 'L', 'i', 'g', 'h', 't'};
char manufname[] = {9, 'E', 's', 'p', 'r', 'e', 's', 's', 'i', 'f'};

/********************* Zigbee functions **************************/
static void bdb_start_top_level_commissioning_cb(uint8_t mode_mask)
{
    ESP_ERROR_CHECK(esp_zb_bdb_start_top_level_commissioning(mode_mask));
}

void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct)
{
    uint32_t *p_sg_p       = signal_struct->p_app_signal;
    esp_err_t err_status = signal_struct->esp_err_status;
    esp_zb_app_signal_type_t sig_type = (esp_zb_app_signal_type_t)*p_sg_p;
    switch (sig_type) {
    case ESP_ZB_ZDO_SIGNAL_SKIP_STARTUP:
        log_i("Zigbee stack initialized");
        esp_zb_bdb_start_top_level_commissioning(ESP_ZB_BDB_MODE_INITIALIZATION);
        break;
    case ESP_ZB_BDB_SIGNAL_DEVICE_FIRST_START:
    case ESP_ZB_BDB_SIGNAL_DEVICE_REBOOT:
        if (err_status == ESP_OK) {
            log_i("Start network steering");
            esp_zb_bdb_start_top_level_commissioning(ESP_ZB_BDB_MODE_NETWORK_STEERING);
        } else {
            /* commissioning failed */
            log_w("Failed to initialize Zigbee stack (status: %s)", esp_err_to_name(err_status));
        }
        break;
    case ESP_ZB_BDB_SIGNAL_STEERING:
        if (err_status == ESP_OK) {
            esp_zb_ieee_addr_t extended_pan_id;
            esp_zb_get_extended_pan_id(extended_pan_id);
            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)",
                     extended_pan_id[7], extended_pan_id[6], extended_pan_id[5], extended_pan_id[4],
                     extended_pan_id[3], extended_pan_id[2], extended_pan_id[1], extended_pan_id[0],
                     esp_zb_get_pan_id(), esp_zb_get_current_channel(), esp_zb_get_short_address());
        } else {
            log_i("Network steering was not successful (status: %s)", esp_err_to_name(err_status));
            esp_zb_scheduler_alarm((esp_zb_callback_t)bdb_start_top_level_commissioning_cb, ESP_ZB_BDB_MODE_NETWORK_STEERING, 1000);
        }
        break;
    case ESP_ZB_NWK_SIGNAL_PERMIT_JOIN_STATUS:
      Serial.println("\n ESP_ZB_NWK_SIGNAL_PERMIT_JOIN_STATUS...\n");
        if (err_status == ESP_OK) {
                Serial.println("\n ESP_ZB_NWK_SIGNAL_PERMIT_JOIN_STATUS 1...\n");
            if (*(uint8_t *)esp_zb_app_signal_get_params(p_sg_p)) {
              Serial.println("\n ESP_ZB_NWK_SIGNAL_PERMIT_JOIN_STATUS 3...\n");
                ESP_LOGI(TAG, "Network(0x%04hx) is open for %d seconds", esp_zb_get_pan_id(), *(uint8_t *)esp_zb_app_signal_get_params(p_sg_p));
            } else {
              Serial.println("\n ESP_ZB_NWK_SIGNAL_PERMIT_JOIN_STATUS 1...\n");
                ESP_LOGW(TAG, "Network(0x%04hx) closed, devices joining not allowed.", esp_zb_get_pan_id());
            }
        }
        break;
    default:
        log_i("ZDO signal: %s (0x%x), status: %s", esp_zb_zdo_signal_to_string(sig_type), sig_type,
                 esp_err_to_name(err_status));
        break;
    }
}

static esp_err_t zb_action_handler(esp_zb_core_action_callback_id_t callback_id, const void *message)
{
  Serial.println("\n zb_action_handler...\n");
    esp_err_t ret = ESP_OK;
    switch (callback_id) {
    case ESP_ZB_CORE_SET_ATTR_VALUE_CB_ID:
      Serial.println("\n ESP_ZB_CORE_SET_ATTR_VALUE_CB_ID...\n");
        ret = zb_attribute_handler((esp_zb_zcl_set_attr_value_message_t *)message);
        break;
    default:
    Serial.println("\n Receive Zigbee action...\n");
        log_w("Receive Zigbee action(0x%x) callback", callback_id);
        break;
    }
    return ret;
}

static void esp_zb_task(void *pvParameters)
{
    // initialize Zigbee stack with Zigbee end-device config 
    esp_zb_cfg_t zb_nwk_cfg = ESP_ZB_ZED_CONFIG();
    esp_zb_init(&zb_nwk_cfg);
    esp_zb_set_primary_network_channel_set(ESP_ZB_PRIMARY_CHANNEL_MASK);

    // set the on-off light device config
    uint8_t test_attr, test_attr2;
 
    test_attr = 0;
    test_attr2 = 4;
    // basic cluster create with fully customized
    esp_zb_attribute_list_t *esp_zb_basic_cluster = esp_zb_zcl_attr_list_create(ESP_ZB_ZCL_CLUSTER_ID_BASIC);
    esp_zb_basic_cluster_add_attr(esp_zb_basic_cluster, ESP_ZB_ZCL_ATTR_BASIC_ZCL_VERSION_ID, &test_attr);
    esp_zb_basic_cluster_add_attr(esp_zb_basic_cluster, ESP_ZB_ZCL_ATTR_BASIC_POWER_SOURCE_ID, &test_attr2);
    esp_zb_cluster_update_attr(esp_zb_basic_cluster, ESP_ZB_ZCL_ATTR_BASIC_ZCL_VERSION_ID, &test_attr2);
    esp_zb_basic_cluster_add_attr(esp_zb_basic_cluster, ESP_ZB_ZCL_ATTR_BASIC_MODEL_IDENTIFIER_ID, &modelid[0]);
    esp_zb_basic_cluster_add_attr(esp_zb_basic_cluster, ESP_ZB_ZCL_ATTR_BASIC_MANUFACTURER_NAME_ID, &manufname[0]);
    // identify cluster create with fully customized
    esp_zb_attribute_list_t *esp_zb_identify_cluster = esp_zb_zcl_attr_list_create(ESP_ZB_ZCL_CLUSTER_ID_IDENTIFY);
    esp_zb_identify_cluster_add_attr(esp_zb_identify_cluster, ESP_ZB_ZCL_ATTR_IDENTIFY_IDENTIFY_TIME_ID, &test_attr);
    // group cluster create with fully customized
    esp_zb_attribute_list_t *esp_zb_groups_cluster = esp_zb_zcl_attr_list_create(ESP_ZB_ZCL_CLUSTER_ID_GROUPS);
    esp_zb_groups_cluster_add_attr(esp_zb_groups_cluster, ESP_ZB_ZCL_ATTR_GROUPS_NAME_SUPPORT_ID, &test_attr);
    // scenes cluster create with standard cluster + customized
    esp_zb_attribute_list_t *esp_zb_scenes_cluster = esp_zb_scenes_cluster_create(NULL);
    esp_zb_cluster_update_attr(esp_zb_scenes_cluster, ESP_ZB_ZCL_ATTR_SCENES_NAME_SUPPORT_ID, &test_attr);
    // on-off cluster create with standard cluster config
    esp_zb_on_off_cluster_cfg_t on_off_cfg;
    on_off_cfg.on_off = ESP_ZB_ZCL_ON_OFF_ON_OFF_DEFAULT_VALUE;
    esp_zb_attribute_list_t *esp_zb_on_off_cluster = esp_zb_on_off_cluster_create(&on_off_cfg);
    // create cluster lists for this endpoint
    esp_zb_cluster_list_t *esp_zb_cluster_list = esp_zb_zcl_cluster_list_create();
    esp_zb_cluster_list_add_basic_cluster(esp_zb_cluster_list, esp_zb_basic_cluster, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);
    // update basic cluster in the existed cluster list
    //esp_zb_cluster_list_update_basic_cluster(esp_zb_cluster_list, esp_zb_basic_cluster_create(NULL), ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);
    esp_zb_cluster_list_add_identify_cluster(esp_zb_cluster_list, esp_zb_identify_cluster, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);
    esp_zb_cluster_list_add_groups_cluster(esp_zb_cluster_list, esp_zb_groups_cluster, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);
    esp_zb_cluster_list_add_scenes_cluster(esp_zb_cluster_list, esp_zb_scenes_cluster, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);
    esp_zb_cluster_list_add_on_off_cluster(esp_zb_cluster_list, esp_zb_on_off_cluster, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);

    esp_zb_ep_list_t *esp_zb_ep_list = esp_zb_ep_list_create();
    // add created endpoint (cluster_list) to endpoint list
    esp_zb_ep_list_add_ep(esp_zb_ep_list, esp_zb_cluster_list, HA_ESP_LIGHT_ENDPOINT, ESP_ZB_AF_HA_PROFILE_ID, ESP_ZB_HA_ON_OFF_OUTPUT_DEVICE_ID);
    esp_zb_device_register(esp_zb_ep_list);
    esp_zb_core_action_handler_register(zb_action_handler);
    ESP_ERROR_CHECK(esp_zb_start(false));
    esp_zb_main_loop_iteration();
}

/* Handle the light attribute */

static esp_err_t zb_attribute_handler(const esp_zb_zcl_set_attr_value_message_t *message)
{
      Serial.println("\n zb_attribute_handler...\n");
    esp_err_t ret = ESP_OK;
    bool light_state = 0;

    if(!message){
      log_e("Empty message");
    }
    if(message->info.status != ESP_ZB_ZCL_STATUS_SUCCESS){
      log_e("Received message: error status(%d)", message->info.status);
    }

    log_i("Received message: endpoint(%d), cluster(0x%x), attribute(0x%x), data size(%d)", message->info.dst_endpoint, message->info.cluster,
             message->attribute.id, message->attribute.data.size);
    if (message->info.dst_endpoint == HA_ESP_LIGHT_ENDPOINT) {
        if (message->info.cluster == ESP_ZB_ZCL_CLUSTER_ID_ON_OFF) {
            if (message->attribute.id == ESP_ZB_ZCL_ATTR_ON_OFF_ON_OFF_ID && message->attribute.data.type == ESP_ZB_ZCL_ATTR_TYPE_BOOL) {
                light_state = message->attribute.data.value ? *(bool *)message->attribute.data.value : light_state;
                log_i("Light sets to %s", light_state ? "On" : "Off");
                neopixelWrite(LED_PIN,255*light_state,255*light_state,255*light_state); // Toggle light
            }
        }
    }
    return ret;
}

/********************* Arduino functions **************************/
void setup() {
    // Init Zigbee
    esp_zb_platform_config_t config = {
        .radio_config = ESP_ZB_DEFAULT_RADIO_CONFIG(),
        .host_config = ESP_ZB_DEFAULT_HOST_CONFIG(),
    };
    ESP_ERROR_CHECK(nvs_flash_init());
    ESP_ERROR_CHECK(esp_zb_platform_config(&config));

    // Init RMT and leave light OFF
    neopixelWrite(LED_PIN,0,0,0);

      delay(1000);
  Serial.begin(115200);
  delay(1000);
  Serial.println("\n starting...\n");
    //Start Zigbee task
    xTaskCreate(esp_zb_task, "Zigbee_main", 4096, NULL, 5, NULL);
}

void loop() {
    //empty, zigbee running in task
}

@snell

I'M not sure why , log_i and log_e statements do not work for me.
SO I added some serial.println replacing them.

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

any idea about what's missing ?

Not sure. I was working at mine for so long tweaking things to get it working that once it started working I did not try much else. The color dimmable is failing for me (constantly) but it has different messaging in the log... so I need a break from it.

I will remove my On/Off and see if I can add it back in. If that works, I will see if I can try making an Arduino version.

UPDATE: I was able to remove and add it back in (although it did not want to do it until after a reboot). But I have not gotten the Arduino version of it working... probably same thing you are seeing. Never gets past initializing (same thing as the original examples until all the extra stuff was added).

UPDATE 2 (last tonight): I could not get it working in the Arduino... I think maybe some of their underlying stuff might not ready yet? Who knows. Either way, I am probably not going to endear myself with Espressif's people... because I posted a comment on the Arduino ZigBee Issue asking if there are plans to update the example to be able to connect to hubs (and mentioning the extra code needed for that to work properly). I also mentioned the lack of any real Serial monitor output. Cannot hurt to ask. The whole point of such examples is that they are supposed to work "out of the box" or with whatever minimal instructions needed. If it is not going to be able to connect to a hub and they are not going to make an example that will... that would be good to know also.

1 Like

is your nickname there "fillibar" ?

btw, do you recommend using Espressif IDE for someone who does not have any experience with it ? Do you use VS or Eclipse ?

@snell

I opened this ticket under esp-zigbee-sdk/issues as requested there:

maybe we can follow up on this.

Well... I figured out the Espressif IDF (it is not a development environment, just a way to build and flash the code to the devices) without TOO much trouble, at least the bare minimum commands:

idf.py set-target esp32c6
idf.py build
idf.py flash
idf.py monitor

Plus I needed idf.py menuconfig to set some of the configuration stuff (like whether ZigBee was an endpoint and how much flash memory the c6 has). That thing's UI is worse than what I remember BIOS menus being back in the 90s.

The actual code editing in the .c file I just did with Notepad++.

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: