ESP32C6 Arduino 3.00 and Zigbee Support

I am trying to compile the Zigbee Switch and Lamp Arduino examples using PlatformIO. The code compiles, and uploads and appears to run, however its not actually doing what it is supposed to do. The network startup (“Steering” in Zigbee) doesn’t appear to work as it runs for a very short time compared to the same code when compiled from the Arduino IDE, and it never finds and joins a coordinator.

I suspect it may be either related to a mismatched or missing library, but I’d expect a build failure rather than runtime issues, or possibly related to how Zigbee is using the extra FAT partitions on the flash.

I’d really appreciate any input or ideas - I really don’t want to rely on the Arduino IDE for this, it’s so clumsy after using PlatformIO/VSCode.

To get this to work I have had to make a lot of changes to the config to get PlatformIO to support the new Arduino framework, but everything seems to be OK.

I have added a file to the boards definitions (in the platforms/espressif32/boards/ folder) that was configured for esp32c6 and enabled the Arduino framework.

Added support for the new Arduino 3.0.0-rc1 version of the framework.

Added all the extra build time libraries and definitions to the platformio.ini for either a Coordinator or End Device:

[env:seeed_xiao_esp32c6]
platform = espressif32
; platform = espressif32 @ ^6.6.0
board = seeed_xiao_esp32c6
board_build.partitions = partitions.csv
board_build.f_cpu = 160000000L
framework = arduino
platform_packages = 
	platformio/framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.0-rc1
	platformio/framework-arduinoespressif32-libs @ https://github.com/espressif/esp32-arduino-libs.git#idf-release/v5.1
upload_speed = 460800
upload_port = /dev/ttyACM0
monitor_speed = 115200
build_flags = 
    -D CORE_DEBUG_LEVEL=5
	-D ARDUINO_USB_MODE=1
	-D ARDUINO_USB_CDC_ON_BOOT=1
	-D ZIGBEE_MODE_ED
        -lesp_zb_api_ed -lesp_zb_cli_command -lzboss_stack.ed -lzboss_port

; Depending on the Zigbee mode add this
; -D ZIGBEE_MODE_ZCZR
; -lesp_zb_api_zczr -lesp_zb_cli_command -lzboss_stack.zczr -lzboss_port
; -D ZIGBEE_MODE_ED
; -lesp_zb_api_ed -lesp_zb_cli_command -lzboss_stack.ed -lzboss_port
; -D ZIGBEE_MODE_GPD
; -lesp_zb_api_gpd  -lesp_zb_cli_command -lzboss_stack.gpd -lzboss_port
; -D ZIGBEE_MODE_RCP
; -lesp_zb_api_rcp -lesp_zb_cli_command -lzboss_stack.rcp -lzboss_port

The partition.csv is defined based on the Arduino IDE version that you select from their menu:

# Name,     Type, SubType, Offset,  Size, Flags
nvs,        data, nvs,     0x9000,  0x5000,
otadata,    data, ota,     0xe000,  0x2000,
app0,       app,  ota_0,   0x10000, 0x140000,
app1,       app,  ota_1,   0x150000,0x140000,
spiffs,     data, spiffs,  0x290000,0x15B000,
zb_storage, data, fat,     0x3EB000,0x4000,
zb_fct,     data, fat,     0x3EF000,0x1000,
coredump,   data, coredump,0x3F0000,0x10000,

When compiled and flashed from the Arduino IDE, I get the following output on my Serial device showing a successfuly connection to my Coordinator…

Starting Zigbee Switch
Zigbee Switch Looping...
Config Ready
Zigbee stack initialized
Start network steering
Joined network successfully (Extended PAN ID: 76:55:e5:ba:33:25:b5:eb, PAN ID: 0x736d, Channel:15, Short Address: 0x5126)

However, the exact same code, compiled and flashed from PlatformIO gives the following output…

Starting Zigbee Switch
Config Ready
Zigbee stack initialized
Start network steering
Zigbee Switch Looping...
Restart network steering (status: ESP_FAIL)
Restart network steering (status: ESP_FAIL)
Restart network steering (status: ESP_FAIL)
Restart network steering (status: ESP_FAIL)
Restart network steering (status: ESP_FAIL)
Restart network steering (status: ESP_FAIL)
Restart network steering (status: ESP_FAIL)
Restart network steering (status: ESP_FAIL)

With the Arduino IDE version, if I don’t have a coordinator open for connections, then the code will also cycle over the ESP_FAIL attempts, but it will take about 2 minutes for each attempt. The PlatformIO version cycles around every 5 seconds so it seems like it is not really doing a full scan, but aborts sooner.

Hi Euan,

I’m also trying to get the zb switch and lamp examples running on XIAO ESP32C6. My standard platform is PlatformIO, but I started in Arduino IDE as the instruction in arduino-esp32/libraries/ESP32/examples/Zigbee/Zigbee_Light_Switch at master · espressif/arduino-esp32 · GitHub was for Arduino IDE. But even there the program crashed probably due to missing partioning of zb_storage. And I gave up setting up another partitioning schememe for A IDE.
Could you share a little more detail about what you added to platforms/espressif32/boards/ folder. And did you add something for the Arduino 3.0.0-rc1 version of the framework, outside of the platformio.ini?
Regards,
Dag

Oh my, kinda hacky. Can you just use the Tasmota version of the Espressif32 platform? It has support for the Arduino-ESP32 3.0.0 in a definitely confirmed-working way. Just set

platform = https://github.com/Jason2866/platform-espressif32#Arduino/IDF5
board = esp32-c6-devkitc-1

in the platformio.ini as a starting point.

Hi Dag,

I just really copied and modified the existing “esp32-c6-devkitm-1.json” one, but customised for my particular board - the Seeed XIAO C6 board - this gives me the additional definitions for the GPIO ports etc that map to my device.

The only other change I made here was to add the arduino platform as this is not yet enabled on the esp32-c6-devkitm-1.json definition.

"frameworks": [
    "arduino",
    "espidf"
  ],

You can just add the platform on the esp32-c6-devkitm-1.json definition and do your GPIO etc mapping directly.

Just one more thing, if you use the esp32-c6-devkitm-1 board in the Arduino IDE, you should see the two Zigbee partitions available directly from the menu. (Make sure you use the m1 board variant as it is configured with 4Mb of memory, the c1 tries to use 8Mb and things break.)

Regards,

Euan.

Hi @maxgerhardt
Thanks for the steer to using the Tasmota fork.

I have now tried using the Tasmota fork, but it doesn’t appear to have the Zigbee components in the Arduino Library.

   34 | #include "esp_zigbee_core.h"
      |          ^~~~~~~~~~~~~~~~~~~
compilation terminated.

Looking directly in the zip files Arduino Library releases here
https://github.com/tasmota/arduino-esp32/releases

I cannot see either the Zigbee include files, or the associated libraries (libesp_zb* and libzboss*).

If I keep the Tasmota fork, but still pull in the official arduino libraries I can get it to compile, but I am back to where I started, it runs, but doesn’t appear to be communicating over the radio as the network startup cycle is still too fast.

Does the Tasmota fork plan to support Zigbee on the supported ESP32 chips?

Now I have failed with ArdionoIDE and PlatformIO.

I installed the Espressif ESP-IDF IDE, and got both light and switch working.

I still prefer PlatformIO, but wanted a working zb example on Seeed XIAO esp32c6, as a reference.

After installing ESP-IDF IDE (in vscode on linux), I clicked the Show examples button on the ESP-IDF Welcome page, searched HA and found light_sample with the projects HA_on_off_light and HA_on_off_switch.
The only code change I made was to replace the rgb led strip driver with the gpio15 led on the seeed board. The switch used was already gpio9 - the boot button.
after flashing and starting the boards I could toggle the light board led on-off with the boot button on the switch board.

The ESP-IDF IDE experience was: it worked, but suffered from file bloat. It was unclear which files to store in git, so I ended up pushing over 200 files to the repo.

I hope we could find how to do the same in PlatformIO.

My code is available in GitHub - dagrende/HA_on_off_switch and GitHub - dagrende/HA_on_off_light.

Platform Espressif32@6.6.0 comes with ESP-IDF version 5.2.1 which has ZigBee support included.

There should be no problems with PlatformIO in pure ESP-IDF projects.

Thank you for this!
I wasn’t aware of the platform.ini syntax:
platform = espressif32 @ 6.6.0

By adding the needed zigbee partitioning table to the ini I may be able to go back to my favourite IDE.

1 Like

No, there is no plan to include the Zigbee support (precompiled libs) in Tasmota fork.
We will not use the embedded zigbee. Zigbee and WiFi using together is working badly.
The share the same hardware. Works as bad as using WiFi and BLE together.
Since WiFi is always needed for Tasmota the zigbee part is obsolete.
Good designs which uses wifi and zigbee needs two MCUs.

1 Like

@dagrende did you ever get the Zigbee example working with PIO?