This is a Matter Generic Switch (device type 0x000F) — a momentary button that sends press/release/multipress events over Thread. Built with ESP-IDF and Espressif's SDK for Matter.
Evolved from my light fixture project.
Note: use your own device, partition name and other parameters value. This is not a complete guide.
- https://wiki.seeedstudio.com/xiao_esp32_matter_env/
- https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/macos-setup.html
- https://docs.espressif.com/projects/esp-matter/en/latest/esp32/developing.html
- https://docs.espressif.com/projects/esp-matter/en/latest/esp32/esp-matter-en-master-esp32.pdf
Clone this repo to the esp-matter directory.
Open IDF Terminal, navigate to esp-matter directory.
source ./export.shexport IDF_CCACHE_ENABLE=1
idf.py fullclean
rm -rf build/
esptool.py --chip esp32c6 --port /dev/cu.usbmodem2101 erase_flashNavigate to this project directory.
idf.py set-target esp32c6idf.py buildidf.py -p /dev/cu.usbmodem2101 flash
Should be enabled before. It was disabled here.
idf.py -p /dev/cu.usbmodem2101 monitoresp-matter-mfg-tool -n 1 \
-v 0xFFF1 -p 0x8001 \
--vendor-name "ChaikaMatter" \
--product-name "Smart_Button" \
--hw-ver 1 --hw-ver-str "1.0"esptool.py --chip esp32c6 --port /dev/cu.usbmodem2101 write_flash 0x10000 out/fff1_8001/**/**-partition.binAn external UFL antenna is used for Thread communication. The FM8625H RF switch on the XIAO ESP32-C6 is configured at startup via GPIO3 (enable) and GPIO14 (antenna select).
Push button on GPIO20 (XIAO ESP32-C6 D9 pin), active low. The button is a Matter momentary switch with the following supported events:
| Action | Matter Event |
|---|---|
| Single press | InitialPress |
| Release | CurrentPosition reset to 0 |
| Long press (5s) | LongPress (also triggers factory reset) |
| Multi-press | MultiPressOngoing + MultiPressComplete (up to 5 presses) |