The demo application is intended to work on following categories of ESP32 devices:
Building the example application requires the use of the Espressif IoT Development Framework (ESP-IDF).
The VSCode devcontainer has these components pre-installed, so you can skip this step. To install these components manually, follow these steps:
Clone the Espressif ESP-IDF and checkout v4.4 release
$ mkdir ${HOME}/tools $ cd ${HOME}/tools $ git clone https://github.com/espressif/esp-idf.git $ cd esp-idf $ git checkout v4.4 $ git submodule update --init $ ./install.sh
Install ninja-build
$ sudo apt-get install ninja-build
Currently building in VSCode and deploying from native is not supported, so make sure the IDF_PATH has been exported(See the manual setup steps above).
Setting up the environment
$ cd ${HOME}/tools/esp-idf $ ./install.sh $ . ./export.sh $ cd {path-to-connectedhomeip}
To download and install packages.
$ source ./scripts/bootstrap.sh $ source ./scripts/activate.sh
If packages are already installed then simply activate them.
$ source ./scripts/activate.sh
Target Set
$ idf.py set-target esp32 or $ idf.py set-target esp32c3 or $ idf.py set-target esp32s3
To build the demo application.
$ idf.py build
After building the application, to flash it outside of VSCode, connect your device via USB. Then run the following command to flash the demo application onto the device and then monitor its output. If necessary, replace /dev/tty.SLAB_USBtoUART
(MacOS) with the correct USB device name for your system(like /dev/ttyUSB0
on Linux). Note that sometimes you might have to press and hold the boot
button on the device while it's trying to connect before flashing.
$ idf.py -p /dev/tty.SLAB_USBtoUART flash monitor
Note: Some users might have to install the VCP driver before the device shows up on /dev/tty
.
Quit the monitor by hitting Ctrl+]
.
Note: You can see a menu of various monitor commands by hitting Ctrl+t Ctrl+h
while the monitor is running.
If desired, the monitor can be run again like so:
$ idf.py -p /dev/tty.SLAB_USBtoUART monitor
Please build the standalone chip-tool as described here
Commissioning the Lighting device
$ ./out/debug/chip-tool pairing ble-wifi 12345 <ssid> <passphrase> 20202021 3840
After successful commissioning, use the OnOff cluster command to control the OnOff attribute. This allows you to toggle a parameter implemented by the device to be On or Off.
$ ./out/debug/chip-tool onoff on 12345 1
On ESP32C3-DevKitM or ESP32S3-DevKitM board, there is an on-board RGB-LED. Use ColorControl cluster command to control the color attributes:
$ ./out/debug/chip-tool colorcontrol move-to-hue-and-saturation 240 100 0 0 0 12345 1
Before moving ahead, make sure your device is commissioned and running.
scripts/examples/gn_build_example.sh examples/ota-provider-app/linux out/debug chip_config_network_layer_ble=false
./out/debug/chip-ota-provider-app -f hello-world.bin
hello-world.bin can be obtained from compiling the hello-world ESP-IDF example.
./out/debug/chip-tool pairing onnetwork 12346 20202021
After commissioning is successful, press Enter in requestor device console and type below query.
>matter ota query 1 12346 0
Once the transfer is complete, OTA requestor sends ApplyUpdateRequest command to OTA provider for applying the image. Device will restart on successful application of OTA image.