Files
esp-matter/README.md
T
Hrishikesh Dhayagude 9af0fae34e ESP Matter beta release
2021-08-11 20:19:49 +05:30

126 lines
4.5 KiB
Markdown

# ESP Matter
[Matter](https://buildwithmatter.com/) is the unified IP-based connectivity protocol built on proven technologies, helping connect and build reliable, secure IoT ecosystems. This new technology and royalty-free connectivity standard enables communications among a wide range of smart devices.
ESP Matter is the official Matter development framework for the Espressif's ESP32 series SoCs.
## Development Setup
This sections talks about setting up your development host, fetching the git repositories, and instructions to build and flash.
### Host Setup
You should install drivers and support packages for your development host. Windows, Linux and Mac OS-X, are supported development hosts. Please see [Get Started](https://docs.espressif.com/projects/esp-idf/en/v4.3/esp32/index.html) for the host setup instructions.
### Getting the Repositories
This only needs to be done once:
```
$ git clone --recursive https://github.com/espressif/esp-idf.git
$ cd esp-idf
$ git checkout v4.3
$ git submodule update --init --recursive
$ ./install.sh
$ cd ..
$ git clone --recursive https://glab.espressif.cn/esp-matter-preview/esp-matter.git
$ cd esp-matter/connectedhomeip/connectedhomeip
$ source scripts/bootstrap.sh
```
### Configuring the environment
This needs to be done everytime a new terminal is opened:
```
$ cd /path/to/esp-idf
$ . export.sh
$ cd /path/to/esp-matter/
$ . export.sh
$ cd examples/light/
$ export ESPPORT=/dev/cu.SLAB_USBtoUART (or /dev/ttyUSB0 or /dev/ttyUSB1 on Linux or COMxx on MinGW)
```
### Building and Flashing the Firmware
Selecting board:
```
$ idf.py menuconfig
```
* menuconfig -> ESP Matter Board Selection -> Select the supported board
* The boards here are dependent on the IDF_TARGET. If your board uses a different chip, set the correct target and try again.
```
idf.py set-target esp32c3 (or esp32 or other supported targets)
```
* The other peripheral components like led_driver, button_driver, etc are selected based on the board selected.
* The configuration of the peripheral components can be found in `esp-matter/components/board/<board_name>/board.c`.
* If the board that you have is of a different revision, and is not working as expected, the GPIO and other configuration can be changed in the `board.c` file.
Build and flash:
```
$ idf.py build
$ idf.py flash monitor
```
* Note: If you are getting build errors like:
```
ERROR: This script was called from a virtual environment, can not create a virtual environment again
```
Run:
```
pip install -r $IDF_PATH/requirements.txt
```
## Test Setup (Python Controller Setup)
### Environment setup
```
$ cd esp-matter/connectedhomeip/connectedhomeip
$ ./scripts/build_python.sh -m platform
$ source out/python_env/bin/activate
```
### Commissioning
Execute the controller and establish a secure session over BLE.
```
$ chip-device-ctrl
chip-device-ctrl > ble-scan
chip-device-ctrl > connect -ble 3840 20202021 12344321
```
* Discriminator: 3840 (configurable through menuconfig)
* Setup-pin-code: 20202021 (configurable through menuconfig)
* Node ID: Optional. If not passed in this command, then it is auto-generated by the controller and displayed in the output of connect. The same value should be used in the next commands. We have chosen a random node ID which is 12344321.
Add credentials of the Wi-Fi network you want the device to connect to.
```
chip-device-ctrl > zcl NetworkCommissioning AddWiFiNetwork 12344321 0 0 ssid=str:TESTSSID credentials=str:$TESTPASSWD breadcrumb=0 timeoutMs=1000
chip-device-ctrl > zcl NetworkCommissioning EnableNetwork 12344321 0 0 networkID=str:TESTSSID breadcrumb=0 timeoutMs=1000
```
Close BLE connection.
```
chip-device-ctrl > close-ble
```
Resolve DNS-SD name and update address of the node in the device controller.
```
chip-device-ctrl > resolve 0 12344321
```
### Cluster Control
Use the cluster commands to control the attributes.
```
chip-device-ctrl > zcl OnOff On 12344321 1 0
chip-device-ctrl > zcl LevelControl MoveToLevel 12344321 1 0 level=10 transitionTime=0 optionMask=0 optionOverride=0
chip-device-ctrl > zcl LevelControl MoveToLevel 12344321 1 0 level=100 transitionTime=0 optionMask=0 optionOverride=0
chip-device-ctrl > zcl ColorControl MoveToSaturation 12344321 1 0 saturation=200 transitionTime=0 optionsMask=0 optionsOverride=0
chip-device-ctrl > zcl ColorControl MoveToHue 12344321 1 0 hue=150 direction=0 transitionTime=0 optionsMask=0 optionsOverride=0
chip-device-ctrl > zcl OnOff Toggle 12344321 1 0
chip-device-ctrl > quit
```