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 this Core 24 release, highlighting the features and tools available to you. 

In this third blog, Farshid Tavakolizadeh, engineering manager from our Industrial team, will show you how to build a Matter lighting device with a Raspberry Pi.

With the release of Matter 1.3, it is now easier than ever to create interoperable home appliances. The standard now supports devices such as refrigerators, air conditioners, dishwashers, ovens, robotic vacuums, and electric vehicle chargers. Smart appliances can use the internet to gain added features, such as remote management and maintenance, but this comes with additional risks and security burdens. Ubuntu Core provides a secure and reliable foundation for running smart home applications that are responsible not only for home appliances but also for critical infrastructure powering smart door locks, garage doors, surveillance and security systems.

Deploy a Matter application on Ubuntu Core

The quickest way to create a Matter application is by using the open source Matter SDK. This provides the foundations at the protocol level, ranging from access control to device definition, leaving you responsible for implementing device control logic. Here, I will show you how to work with our reference application that uses the Matter SDK. This reference application will allow you to create more complex applications, such as for a microwave-oven unit, exposing cooking operations over Matter. 

Raspberry Pi and led configuration 

Our reference application is available here. The matter-pi-gpio-commander is a snap that turns a Raspberry Pi into a Matter lighting device. The application allows the control of the GPIO to switch on and off an LED, over the Matter standard. This application can serve as a template for building your own application from a tested starting point. 

So first, get your RPi and connect an LED as shown in the diagram above. To install Ubuntu Core, follow these steps. After you connect to your device, manually install our reference snap:

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

matter-pi-gpio-commander 2.0.0 from Canonical IoT Labs installed

Next, you need to configure it to use the right GPIO pin and chip:

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

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

Make sure to set the gpio the right value, based on your wiring. Use gpiochip=4 on Raspberry Pi 5 and gpiochip=0 on earlier boards. 

Then, grant the necessary access to your snap:

$ sudo snap connect matter-pi-gpio-commander:custom-gpio matter-pi-gpio-commander:custom-gpio-dev

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

Advertising the device in the local network is done via DNS-SD, which is why we need to connect to avahi snap in the above command. Make sure that Avahi snap is installed.

Finally, we start the application:

$ sudo snap start matter-pi-gpio-commander 

At this point, the Matter application should be running, effectively turning your Raspberry Pi+LED into a Matter Device! This application will use WiFi or Ethernet for networking. 

Control the device over Matter

Now, let’s see the various ways to pair and control your device remotely, from your developer machine. The device is compliant with the Matter standard, and as a result, any compliant Matter Controller should work.

We often find it more practical to use Chip Tool, an open source controller for Linux. This has a command line interface and produces a good level of debugging information. Chip Tool can be installed as a snap. Install it on your development machine:

$ sudo snap install chip-tool

chip-tool v1.2.0.1+snap from Canonical IoT Labs installed

Make sure to have the avahi-daemon installed as it is required for the device discovery.

Then, pair and control the device:

$ sudo chip-tool pairing onnetwork 110 20202021

$ sudo chip-tool onoff on 110 1

That’s it! You just turned on the light!

Led control with Matter 

You may use another Matter Controller such as Google Home. To do this, follow these instructions to add your device as a test project. This is needed because this device hasn’t been certified with Matter.

If you find yourself interested in an open source Controller, read our Home Assistant guide and use it in your next smart home project.

When using a controller with a graphical user interface, you often need to scan a QR code to pair the device. This QR code can be generated by following the link in the Matter application logs. For example, here is a snippet taken from the matter-pi-gpio-commander snap logs:

Copy/paste the below URL in a browser to see the QR Code:
https://project-chip.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J042C00KA0648G00

What’s next?

Try building your own device on top of the Matter SDK. If you find it complicated to build the SDK and package your application, use the Matter SDK plugin for Snapcraft which takes away most of the complexity.

Instead of WiFi/Ethernet, you may want to use Thread networking for your device. You could utilize OpenThread implementations to bootstrap your implementation. The OpenThread Border Router can be installed on Ubuntu Core as a snap.

Build a snap and integrate your application into the Ubuntu Core architecture to leverage application security and over-the-air updates at the edge. In production, the operations we did manually to install and configure the snap will be baked into the Ubuntu Core image itself. The image can be tailored to target smart home requirements, with the right suite of applications and user control. Follow the guide on building your first image to learn more. 

And finally, check out the Matter on Ubuntu documentation, where we have several other guides and examples that could help you get started with your smart home projects.

smart start

IoT as a service

Bring an IoT device to market fast. Focus on your apps, we handle the rest. Canonical offers hardware bring up, app integration, knowledge transfer and engineering support to get your first device to market. App store and security updates guaranteed.

Get your IoT device to market fast ›

smart start logo

IoT app store

Build a platform ecosystem for connected devices to unlock new avenues for revenue generation. Get a secure, hosted and managed multi-tenant app store for your IoT devices.

Build your IoT app ecosystem ›

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

EdgeIQ and Ubuntu Core; bringing security and scalability to device management 

Today, EdgeIQ and Canonical announced the release of the EdgeIQ Coda snap and official support of Ubuntu Core on the EdgeIQ Symphony platform. EdgeIQ Symphony...

Space pioneers: Lonestar gears up to create a data centre on the Moon

Why establish a data centre on the Moon? Find out in our blog.

A look into Ubuntu Core 24: Robotics telemetry for your fleet

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