Your submission was sent successfully! Close

Thank you for signing up for our newsletter!
In these regular emails you will find the latest updates from Canonical and upcoming events where you can meet our team.Close

Thank you for contacting our team. We will be in touch shortly.Close

  1. Blog
  2. Article

Nathan Hart
on 11 May 2023

Matter on Ubuntu: getting started with the standard for smart home devices


Canonical joined the Connectivity Standards Alliance last year to lead the charge for Linux in the smart home. The Matter standard is a particular focus for us. Its secure design and open ecosystem align well with Ubuntu’s own values of security and openness.

Ubuntu Core and Matter make for a powerful pair. Ubuntu Core’s containerisation makes it a highly secure OS that pairs well with the highly secure protocol. Its update and device management capabilities provide the missing pieces that the Matter standard leaves up to device makers to implement.

Since joining the alliance, we’ve been working to support the Matter standard on Ubuntu and Ubuntu Core. As part of that effort, we’ve created a set of reference snaps which enable the creation of a Matter fabric running entirely on Ubuntu. 

This blog is a how-to guide for creating a Matter fabric running entirely on Ubuntu devices. In it, we’ll describe how to set up a simple end device (in this case a light) and then commission and control it with our controller snap.

Hardware

In this guide, we use the following hardware:

  • A PC running Ubuntu 22.04
  • A Raspberry Pi 4B with a 64bit Ubuntu 22.04
  • A 10mm 3v LED

Since we use a large 3v LED, we can directly connect it to the GPIO. We connect the LED to GPIO 4 (pin 7) and GND (pin 9). Read more about the Raspberry Pi pinout.

Installation

In this section, we’ll install a Matter application to turn the Raspberry Pi into a Matter lighting device. We will use the matter-pi-gpio-commander snap which contains a lighting app built on top of the Matter SDK.

SSH to the Raspberry Pi and install the snap:

sudo snap install matter-pi-gpio-commander --beta

Set the GPIO to 4:

sudo snap set matter-pi-gpio-commander gpio=4

Read the instructions for other possible configurations such as changing the default pass code (i.e. 20202021).

Grant the snap access to the GPIO memory, needed by this application:

sudo snap connect matter-pi-gpio-commander:gpio-memory-control

The application is almost ready to start and join a Matter network. But before doing so, it is better to test it locally to see if we can control the GPIO via the app:

sudo matter-pi-gpio-commander.test-blink

Take a look at the logs and the LED. If there are no errors and the LED blinks every half second, we are ready to proceed!

Before we start the application, we’d also grant it access to register itself via DNS-SD to allow discovery later on:

sudo snap connect matter-pi-gpio-commander:avahi-control

Now, let’s start the application service:

sudo snap start matter-pi-gpio-commander

You can monitor the logs with:

sudo snap logs -n 100 -f matter-pi-gpio-commander

Keep the application running in a dedicated terminal window. We’ll commission and control the application in the next section.

Commissioning

Now that we have our application running, we can go ahead and commission it using a Matter controller.

We will use the chip-tool snap which is a CLI Matter controller.

Install the controller on the PC:

sudo snap install chip-tool --beta

Assuming the Pi and PC are connected to the same network, we should be able to commission the device by discovering its IP address via DNS-SD. This way, we don’t have to manually enter the IP address.

First, grant the necessary access to chip-tool to discover services via DNS-SD:

sudo snap connect chip-tool:avahi-observe

We are ready to pair:

sudo chip-tool pairing onnetwork 110 20202021

where:

  • 110 is the node id being assigned to this device
  • 20202021 is the default setup passcode

If this doesn’t work, it may be because it has taken too long to reach this step and the device has stopped listenning to commissioning requests. Try restarting it on the Pi with sudo snap restart matter-pi-gpio-commander.

Control

There are a few ways to control the device. The toggle command is stateless and simplest.

sudo chip-tool onoff toggle 110 1

You may need to send this command a few time to make the GPIO output state in sync (see issue #14).


By now, you have created a fully containerised Matter controller and end device. To adapt these reference snaps to your purposes, feel free to take a look at the source code, linked below. To read more about Canonical’s approach to smart home technology, take a look at our website or get in touch.

For further instructions and to report issues:

Related posts


Nathan Hart
10 July 2023

An introduction to smart home business models

Ubuntu Article

Smart homes are changing. A modern smart home typically isn’t a self-contained, set-it-and-forget-it, custom installation. It’s a hyper-connected set of devices that work together to automate and enhance the users’ living space. Today’s smart homes contain devices from many manufacturers, running dozens of protocols, interfacing with mult ...


Nathan Hart
5 January 2023

Security in the smart home: considerations for device makers

IoT Article

When people think of home security they usually think of an alarm system with a keypad next to the door. These days, however, home security should have two meanings. I’m here to talk about the second: cybersecurity. In other words, security in the smart home. A recent investigation found that a shocking number of leading ...


Nathan Hart
25 October 2022

Two approaches to IoT prototyping

Ubuntu Engineering

Taking a new device from an idea to production readiness can be a challenge. Hacks or workarounds can help you deliver a proof of concept, but they can negatively impact production devices. A development kit can be great for quickly proving out an idea, but oftentimes the hardware constraints will be more stringent in production ...