Your submission was sent successfully! Close

You have successfully unsubscribed! Close

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

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

Tags: smart home

This article was last updated 1 year ago.


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:

Internet of Things

From home control to drones, robots and industrial systems, Ubuntu Core and Snaps provide robust security, app stores and reliable updates for all your IoT devices.

Newsletter signup

Get the latest Ubuntu news and updates in your inbox.

By submitting this form, I confirm that I have read and agree to Canonical's Privacy Policy.

Related posts

A look into Ubuntu Core 24: Your first Linux-powered Matter device

Welcome to this blog series which explores innovative uses of Ubuntu Core. Throughout this series, Canonical’s Engineers will show what you can build with...

An introduction to smart home business models

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...

Security in the smart home: considerations for device makers

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...