No description
  • Makefile 97.2%
  • C++ 2.7%
Find a file
arphone d3d018c4f3
Some checks are pending
ESP32 Build Pipeline / build-esp32 (push) Has started running
changed to esp action yaml
2026-06-11 16:34:59 +08:00
.forgejo/workflows changed to esp action yaml 2026-06-11 16:34:59 +08:00
border-router test runner 2026-06-11 15:00:55 +08:00
build test runner 2026-06-11 15:00:55 +08:00
device-node test runner 2026-06-11 15:00:55 +08:00
build.sh test runner 2026-06-11 15:00:55 +08:00
flash.sh test runner 2026-06-11 15:00:55 +08:00
README.md test runner 2026-06-11 15:00:55 +08:00

ESP32-C6 Thread Light

Two Arduino sketches for ESP32-C6 using the ESP32 Arduino OpenThread library.

  • border-router: starts a fixed Thread network and exposes a serial console for control/inspection. It sends native OpenThread CoAP light commands to the device node.
  • device-node: joins the same Thread network, exposes a CoAP Light resource, and drives one WS2812/NeoPixel on GPIO8.

The Arduino ESP32 core does not provide a complete Wi-Fi-to-Thread OTBR/Matter border-router application as an Arduino sketch. This border-router sketch is a Thread leader/controller for the local Thread mesh.

Build And Verify

Requirements:

  • arduino-cli
  • ESP32 Arduino core with ESP32-C6 OpenThread support, tested with esp32:esp32 3.3.8

Build both sketches:

./build.sh

Build artifacts are written to build/border-router/ and build/device-node/.

Build one sketch:

./build.sh border-router
./build.sh device-node

Use another ESP32-C6 FQBN:

FQBN=esp32:esp32:XIAO_ESP32C6 ./build.sh

Flash

Build first, then flash each ESP32-C6 by sketch name and serial port:

./flash.sh border-router /dev/cu.usbmodem1101
./flash.sh device-node /dev/cu.usbmodem1201

Enable upload verification:

VERIFY=1 ./flash.sh device-node /dev/cu.usbmodem1201

Equivalent direct command:

arduino-cli compile --fqbn esp32:esp32:esp32c6:CDCOnBoot=cdc,PartitionScheme=huge_app device-node

Runtime

Flash one ESP32-C6 with border-router and another with device-node.

Both sketches use this Thread dataset:

  • Network name: ArcodexThread
  • Channel: 24
  • PAN ID: 0x1234
  • Extended PAN ID: 1122334455667788
  • Network key: 00112233445566778899aabbccddeeff

The device node listens on multicast address ff05::abcd, CoAP resource Light.

Home Assistant

The border-router can expose the Thread light to Home Assistant using MQTT discovery. This is not a full OTBR/Matter bridge; Home Assistant talks MQTT to the ESP32-C6 border-router, and the border-router sends Thread CoAP commands to the device node.

  1. Enable an MQTT broker in Home Assistant.
  2. Build and flash the border-router:
./build.sh border-router
./flash.sh border-router /dev/cu.usbmodem1101
  1. If no settings are saved, the border-router starts a setup portal:
  • WiFi network: Arcodex-Thread-Setup
  • WiFi password: 12345678
  • Portal URL: http://192.168.4.1

Thread is not started while the setup portal is active. This keeps the ESP32-C6 radio free for WiFi association.

  1. Enter WiFi and MQTT settings in the portal. The board saves them in flash and reboots.

On reboot, the border-router connects to the saved WiFi before starting Thread. If it cannot join, it reopens the setup portal with Thread still off and prints the WiFi status/disconnect reason on serial.

You can reopen or reset the portal from the border-router serial console:

  • portal: open the setup portal
  • reset-ha: clear Home Assistant settings and open the setup portal

Home Assistant MQTT discovery topic:

  • homeassistant/light/arcodex_thread_light/config

MQTT control topics:

  • Command: arcodex/thread_light/set
  • State: arcodex/thread_light/state
  • Availability: arcodex/thread_light/availability

On the border-router serial console:

  • Send on to turn the WS2812 on.
  • Send off to turn it off.
  • Send toggle to toggle.
  • Send status to print Thread state.
  • Send portal to open the Home Assistant setup portal.
  • Send reset-ha to clear saved WiFi/MQTT settings and open the setup portal.