A Thread border router is not mandatory to interact with Matter devices
Matter is a “super-standard” for IoT device interoperability: it promotes cooperation between smart things manufacturers and allows to control objects from the local network. It is relatively new, as its first specification version just came out in 2022.
Even if the ability to get devices into market requires an attestation from Matter consortium, it is possible to study how Matter works at a relatively cheap cost.
Matter works over IP-based technologies like Wi-Fi (“Matter-over-WiFi”) and Thread (“Matter-over-Thread”). While the first is generally used for the communication with devices transferring large amount of data (e.g. cameras), the latter is suitable for low-power devices requiring to transfer small amount of data (e.g. sensors or lights).
Matter-over-Thread guarantees communications among a variety of devices and networks and to do so it requires two special “components”: a Thread border Router and a Radio Controller. The Thread Border Router handles communications among different kind of networks (eg. Wi-Fi, Ethernet and Thread) while the Radio Controller handles communication among devices.
How does Matter work
Adding a device to a network with Matter is super-easy: just scan its QR code and that’s it, the device is ready and configured. But what’s in that QR code?
The QR code contains a lot of informations used to integrate the device into the domestic network such as the version of Matter standard, PIN and passkey to authenticate the device in the configuration phase, informations about the device and its vendor - namely the Vendor ID (VID) and Product ID (PID) – and security certifications of conformity to the CSA standard.
In order to produce Matter devices, manufacturers must register to the Connectivity Standard Alliance (CSA), which manages the Matter protocol. It’s CSA to assign the VID to uniquely identify each manufacturer and then each manufacturer uniquely assign PID to its own devices (and so, the union of VID and PID uniquely identify the device). This ensures interoperability and guarantees that a device is coming from a verified manufacturer and that it respects the Matter standard.
When the user scans the QR code (e.g. in the Google Home application on the phone), a pairing is initiated using PIN and informations stored in the QR code itself and the authentication certifies that the device is legitimate. The app also connects the device to the Wi-Fi network or the Thread network and when the pairing is completed, the device is part of the network, being accessible from all the other compatible devices and controllers.
CSA also gives a generic VID for test and development purposes only so that developers can test Matter devices without a formal certification at no cost (and of course, that generic VID cannot be used for commercial products!)
Adding a device to the network: the commissioning
The process of registering and adding a Matter device to a network is called commissioning.
When the user wants to add a new device to network, the Google Home app (or another app capable to add Matter compatible devices) will act as commissioner. It will ask the user to scan the QR code (or to enter a PIN) printed on the device: at this point, the device is temporarily connected to the commissioner, cryptographic keys are exchanged to secure operational connection, informations to join the network are received and and the device is officially part of the network.
Removing a device from the network: the decommissioning
Conversely, the process of removing a Matter device from the network is called decommissioning: it can be requested with an app (e.g. Google Home App) or from the device itself (e.g. pressing a button).
When the device is decommissioned, cryptographic keys are invalidated and the device is reset. At this point the device cannot communicate anymore with the other devices in the network.
A low cost “hands-on” experiment with ESP32
One way to play with Matter on a board without having to buy or configure a Thread border router is using an ESP32: Arduino core for ESP32 in fact gives us the capability to use Arduino IDE and the Arduino framework to deploy a Matter-enabled board.
After installing ESP32 support in ArduinoIDE, just compile and upload the following example to the board (it has been readapted from example script in Arduino-esp32 repository from Espressif):
In the snippet of code, the class of the device configures all the callable methods for the object and callbacks it responds to. In this case, since the board acts as a switch light:
MatterOnOffLight OnOffLight;
…
OnOffLight.toggle();
OnOffLight.onChange(setLightOnOff);
Also note:
OnOffLight.updateAccessory();
This directive ensures that the current state of the light (e.g., whether it is ON or OFF) is correctly reflected on the device and on the controller. This could be useful if, for example, the user presses a button to toggle the light state: updateAccessory() would reflect that change in the Google Home App. Conversely, if the user toggle the light from the application, updateAccessory() would update device state accordingly.
If you want to upload the snippet to ESP32, make sure to set the partition scheme to “Minimal SPIFFS”, to gain some space for the code.
Now it's time to add the device to the local network by choosing to add a "Matter enabled device":
and to enter the pin to begin the commissioning process (the pin is written in the serial output by the sketch, you can also scan the QR code at given the url):
Once the process ends (you should receive a message about the board not being certified but in this case is related to the fact that is just a development device) the board joined network!
In the following video you can see the results of the experiment: the board is controlled from the Google Home mobile application. On the converse, a button on the board also acts as a "switch" lighting or shutting off the led and the status on the mobile app gets updated using Matter protocol.
Top comments (1)
Great share @antigones I got to know about matter support on ESP32, and it's google home compilation.