How to Connect ESP32-C6 to the Matter Network

0 4384 Medium

Introduction

Matter is an open, cross-platform Internet of Things (IoT) connectivity standard and protocol designed to address interoperability and compatibility issues among smart home devices. It has garnered support from leading tech companies such as Google, Apple, Amazon, Microsoft, and more.ESP32-C6 is a chip developed by Espressif Systems that supports WiFi 6, Bluetooth 5 (LE), Zigbee, and Thread protocols. With its low power consumption and cost-effectiveness, it is well suited for use in Matter devices. In this guide, we will use the FireBeetle ESP32-C6 to create a smart light bulb and integrate it into a Matter network.


By following this guide, you will learn the following:
● The advantages and network framework of Matter
● How to set up ESP-IDF and ESP-Matter environment on Ubuntu 20
● How to flash the code onto ESP32-C6
● How to add ESP32-C6 to the Matter network
● How to test and control ESP32-C6

 

Part 1: Advantages and Network Architecture of Matter
 

External Gateway

Currently, some smart device manufacturers adopt cloud-based solutions requiring all devices to communicate with a cloud server. The information transmission path is as follows: pressing a switch - router forwards the information to the cloud server - cloud server processes and distributes the information - router forwards the information to the light bulb - light bulb illuminates. This approach has some drawbacks, such as long data transmission times and high dependency on the external network. Without an external network, all smart controls become ineffective.
 

 

Local Gateway

To address the issues with external gateways, smart device manufacturers have developed local gateways that allow control information to reach the corresponding devices without passing through an external network. This improves stability and enhances privacy and security. The information transmission path is as follows: pressing a switch - local gateway processes and distributes the information - light bulb illuminates. However, due to differences in protocols among major manufacturers, it results in fragmentation of smart home devices, limiting the compatibility to devices within the same ecosystem.
 

 

Matter Gateway

Matter's network architecture is similar to local gateways but solves the problem of device fragmentation. Any device supporting the Matter protocol can be connected, eliminating the distinction between device manufacturers.
 

 

 

Part 2: Environment Setup


Use Hardware

● FireBeetle ESP32-C6 *1
● WS2812 LED *1


Connect the WS2812 LED to IO8 of the FireBeetle ESP32-C6.
 

 

FireBeetle ESP32-C6 Hardware Resources:  https://wiki.dfrobot.com/SKU_DFR1075_FireBeetle_2_Board_ESP32_C6

Environment Setup

● The operating system used is Ubuntu 20 (used as the Matter gateway responsible for receiving and distributing Matter data).
● Set up the ESP-IDF development environment, using version 5.1.1.

【BASH】

git clone --recursive https://github.com/espressif/esp-idf.git

cd esp-idf

git checkout v5.1.1

git submodule update --init --recursive

./install.sh

cd ..

 

● Set up the ESP-Matter development environment.

【BASH】

git clone --depth 1 https://github.com/espressif/esp-matter.git

cd esp-matter

git submodule update --init --depth 1

cd ./connectedhomeip/connectedhomeip

./scripts/checkout_submodules.py --platform esp32 linux --shallow

cd ../..

./install.sh

cd ..

 

● During the installation process, you will see the following print messages.

 

 

● After successful installation, you will see the following information.

 

 

● Configure the environment variables for IDF by navigating to the IDF directory.

【BASH】

cd esp-idf

source ./export.sh

 

● Configure the environment variables for Matter by navigating to the Matter directory.

【BASH】

cd esp-matter

source ./export.sh

 

● Enable IDF build with Ccache to increase build speed.

【BASH】

export IDF_CCACHE_ENABLE=1

 

Part 3: Flashing the Sample Code

 

● Navigate to the light example in esp-matter, compile, and flash the program.

【BASH】

cd esp-matter/example/light/

idf.py set-target esp32c6

idf.py flash

 

● If you encounter permission issues that prevent accessing the serial port and flashing, modify its permissions  first, and then continue with the flashing process.

【BASH】

sudo chmod 666 /dev/ttyACM0

idf.py flash

 

● Once flashing is complete, open the serial port of ESP32-C6, and you will see the following print messages.
 

 

 

● Use the serial port to send Matter commands to configure ESP32-C6 and connect it to Wi-Fi (fill in the Wi-Fi SSID and password).

【BASH】

matter esp wifi connet your-ssid your-password

 

 

Part 4: Connecting to the Matter Network

 

● Switch back to the Linux environment and use chip-tool to pair with ESP32-C6, ensuring that both the Linux environment and ESP32-C6 are on the same local network.

【BASH】

chip-tool pairing onnetwork-long 0x12 20202021 3840

#Here, "0x12" is a custom ID for the C6 node.

 

● After running the above command in Linux, you will see successful pairing debug information on the C6 serial port.

 

 

Part 5: Demonstrating the Results

 

● Use chip-tool on Linux to control ESP32-C6. After executing the commands, you will see corresponding debug information and the WS2812 LED's state changes on the C6 serial port.

【BASH】

chip-tool onoff on 0x12 0x1

chip-tool onoff off 0x12 0x1

#These two commands complete the control of the light

 

 

 

Reference: https://docs.espressif.com/projects/esp-matter/en/latest/esp32/developing.html

 

For those who are not familiar with Linux, you may encounter some issues during the construction process. However, problem-solving is part of the learning process.It is recommended to utilize search engines to find the causes of any issues. Feel free to interact and share your questions and ideas in the comments section.

License
All Rights
Reserved
licensBg
0