- Makefile 97.2%
- C++ 2.7%
|
|
||
|---|---|---|
| .forgejo/workflows | ||
| border-router | ||
| build | ||
| device-node | ||
| build.sh | ||
| flash.sh | ||
| README.md | ||
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 CoAPLightresource, 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:esp323.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.
- Enable an MQTT broker in Home Assistant.
- Build and flash the border-router:
./build.sh border-router
./flash.sh border-router /dev/cu.usbmodem1101
- 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.
- 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 portalreset-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
onto turn the WS2812 on. - Send
offto turn it off. - Send
toggleto toggle. - Send
statusto print Thread state. - Send
portalto open the Home Assistant setup portal. - Send
reset-hato clear saved WiFi/MQTT settings and open the setup portal.