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.