Retrofitting with Matter đź’ˇ: How to Make Any Device Smart

Transforming an old lamp into a Smart Home device using Arduino Nano Matter

Leonardo Cavagnis
9 min read6 days ago

This project demonstrates how you can take something old, like a table lamp, and give it new life by integrating it into your smart home ecosystem.
What’s the goal? To replace the physical switch and control your lamp with a simple voice command, like: “Hey, turn on the lamp!”

A smart home ecosystem connects devices like lights, thermostats, and sensors, allowing them to work together seamlessly through platforms like Apple HomeKit, Google Home, or Amazon Alexa.

Smart Lamp with Matter. Image by author.

Matter: The Language of Smart Home

Matter is a communication protocol designed to unify smart home ecosystems by providing a common language for seamless interoperability between devices from different manufacturers.
With Matter, users can integrate devices across major proprietary ecosystems (such as Amazon, Google, and Apple) and open-source platforms (such as Home-Assistant).

Matter logo. Image by author.

Matter works across several network protocols, ensuring flexibility and interoperability, such as:

  • Wi-Fi: Enables high-bandwidth tasks and direct internet connectivity for remote access.
  • Ethernet: Provides stable, wired connections for fixed or central devices.
  • Thread: A low-power, IPv6-based mesh networking protocol ideal for reliable and scalable IoT communication.
Matter protocol stack. Image by author.

Matter network consists of three key roles:

  • Commissioner: Sets up and adds new devices to the Matter network, typically using a smartphone or hub via Bluetooth Low Energy (BLE).
  • Controller: Manages and controls devices within the network, often integrated into smart home platforms.
  • Accessory Device: The end device in the network, such as a smart lamp or thermostat, that performs specific tasks and responds to user commands.
Matter network topology. Image by author.

In this project, we will use a smartphone with Bluetooth connectivity as the Commissioner, a Google Home device as the Controller, and the Accessory Device (the lamp) will be retrofitted using the Arduino Nano Matter board.

The Arduino Nano Matter is a development board designed to enable the creation of Matter-compatible devices, supporting both Thread connectivity and Bluetooth Low Energy (BLE).

Arduino Nano Matter. Source: Arduino.

Why Retrofit?

Retrofitting offers several benefits. By upgrading existing products, like an old lamp, you can transform them into smart devices without the need to buy new ones, contributing to sustainability. Additionally, it provides a more personalized and customizable solution tailored to your needs.

Sustainability and Smart Home. Image generated by AI.

What you need

  • A 220V lamp (or any 220V appliance to be retrofitted).
  • An Arduino Nano Matter board.
  • A 3.3V relay rated for 220–250VAC (since the output pins of the Arduino Nano Matter board work at 3.3V).
  • Wires, power supply, and basic assembly tools.

Let’s wire!

⚠️ Working with 220V voltage can be dangerous. ⚠️
Always ensure that the system is powered off and disconnected before making any connections. Use appropriate personal protective equipment (such as
gloves) and take necessary precautions to avoid electric shock.

Prepare the Lamp

To integrate the relay, you will need to cut the power cable of your 220V lamp: you will typically find two wires (Live and Neutral), but some devices may have three wires:

  • Live (L): carries the current to the device.
  • Neutral (N): completes the circuit by returning the current.
  • Protective Earth or Ground (PE): provides safety grounding to prevent electrical shock in case of a fault.
Line, Neutral and Ground. Image by author.

What is a Relay?

A relay is an electrically operated switch that allows a low-voltage circuit (like the one controlled by the Arduino board) to control a higher-voltage circuit (like the 220V lamp).

Relays typically have:

  • Common (COM): The terminal where the live wire from the power supply is connected (e.g., the 220V live wire).
  • Normally Open (NO): This terminal is open by default and only connects to COM when the relay is activated. Using the NO terminal ensures that the lamp is off when the relay is not powered.
  • Normally Closed (NC): This terminal is connected to COM by default. When the relay is activated, the connection between NC and COM is opened. Using the NC terminal ensures that the lamp is on when the relay is not powered.

We will use the Normally Open (NO) terminal to ensure that the lamp stays off by default when the relay is not activated.

Relay schematic. Image by author.

Wiring the Lamp to the Relay

After cutting the lamp’s power cable, identify the Live (L) and Neutral (N) wires:

  • Connect the Live (L) wire from the 220V power source to the common (COM) terminal of the relay.
  • Connect the Live (L) wire of the lamp to the Normally Open (NO) terminal of the relay.
  • Connect the lamp’s Neutral (N) wire directly to the power source’s Neutral wire.
  • If present, connect the lamp’s Protective Earth (PE) wire to the power source’s ground.
Lamp and Relay. Image by author.

Connect the Relay to the Arduino board

To connect the relay to the Arduino Nano Matter, you’ll need to use the control side of the relay, which typically includes three pins:

  1. VCC: Connect this pin to the 3.3V pin on the Arduino. This powers the relay coil.
  2. GND: Connect this pin to the GND pin on the Arduino.
  3. IN (or Signal): Connect this pin to one of the GPIO pins on the Arduino (e.g., pin D2). This pin is used to send the control signal to activate or deactivate the relay.
Arduino Nano Matter and Relay. Image by author.

Powering the System

Ensure all connections are secure and properly insulated for safety.

  • Arduino Nano Matter: Connect the 5V pin of the Arduino Nano Matter to a suitable power source or use a USB connection.
  • Lamp: Connect the lamp to the 220VAC power source.

Complete Wiring Diagram

Complete wiring diagram. Image by author.

Software Configuration

We will use the matter_on_off_outlet example from the Matter library of the Silabs Arduino core to configure the Arduino Nano Matter. This example demonstrates how to create a smart outlet device, which can be used to control the power state of an appliance, like a lamp.

The outlet is a standard device profile in the Matter protocol, specifically designed for controlling power outlets. Matter supports different profiles for various appliances (such as lights, sensors, …). In this case, the outlet profile is perfect for controlling the lamp.

Here’s a brief overview of the main parts of the code:

  1. Initialization: The Matter.begin() function sets up the Matter protocol, and matter_outlet.begin() initializes the outlet profile.
  2. Commissioning: The Matter.isDeviceCommissioned() function checks whether the device is commissioned to a Matter hub. If not, it provides a code (manual or QR) for commissioning. This step is necessary to connect the device to the Matter network.
  3. Connection to the Network: After commissioning, the device waits for the Thread network connection using Matter.isDeviceThreadConnected(). Once connected to the network, the device will be able to communicate with the hub and other devices. The matter_outlet.is_online() function checks whether the device is online. If it is online, it means it is ready to receive commands.
  4. LED Feedback: The onboard LED provides feedback on the outlet state. If the outlet is on, the LED lights up.

You will need to modify this code slightly to control the lamp connected to D2 pin. In addition to the onboard LED, you should add digitalWrite(D2, HIGH) and digitalWrite(D2, LOW) to reflect the on/off state of the lamp.

#include <Matter.h>
#include <MatterOnOffPluginUnit.h>

MatterOnOffPluginUnit matter_outlet;
//...
void setup()
{
//...
matter_outlet.begin();

// Set up the onboard LED
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LED_BUILTIN_INACTIVE);

// UPDATE: Initialize the Relay Signal pin (D2)
pinMode(D2, OUTPUT);
digitalWrite(D2, LOW); // Ensure the relay is off at startup

//...
Serial.println("Matter On/Off Plug-in Unit / Outlet");

if (!Matter.isDeviceCommissioned()) {
Serial.println("Matter device is not commissioned");
Serial.println("Commission it to your Matter hub with the manual pairing code or QR code");
Serial.printf("Manual pairing code: %s\n", Matter.getManualPairingCode().c_str());
Serial.printf("QR code URL: %s\n", Matter.getOnboardingQRCodeUrl().c_str());
}
while (!Matter.isDeviceCommissioned()) {
delay(200);
}

Serial.println("Waiting for Thread network...");
while (!Matter.isDeviceThreadConnected()) {
delay(200);
}
Serial.println("Connected to Thread network");

Serial.println("Waiting for Matter device discovery...");
while (!matter_outlet.is_online()) {
delay(200);
}
Serial.println("Matter device is now online");
}

void loop()
{
static bool matter_outlet_last_state = false;
bool matter_outlet_current_state = matter_outlet.get_onoff();

// If the current state is ON and the previous was OFF - turn on the LED
if (matter_outlet_current_state && !matter_outlet_last_state) {
matter_outlet_last_state = matter_outlet_current_state;
digitalWrite(LED_BUILTIN, LED_BUILTIN_ACTIVE);
digitalWrite(D2, HIGH); // UPDATE: Activate the Relay
Serial.println("Outlet ON");
}

// If the current state is OFF and the previous was ON - turn off the LED
if (!matter_outlet_current_state && matter_outlet_last_state) {
matter_outlet_last_state = matter_outlet_current_state;
digitalWrite(LED_BUILTIN, LED_BUILTIN_INACTIVE);
digitalWrite(D2, LOW); // UPDATE: Deactivte the Relay
Serial.println("Outlet OFF");
}

//...
}

Smart Device in Action

For testing the smart lamp, I will use the Google Home ecosystem, specifically the Google Nest Hub (2nd Gen). This device acts as a Matter hub and supports the Thread protocol. Note that not all Google Home products support Thread; you can find the list of supported hubs in the Nano Matter user manual.

Google Nest Hub (2nd Gen). Source: Google store.

Preparing the Device

After uploading the code to the Arduino board, open the Serial Monitor in the Arduino IDE. The credentials required to commission the device will appear here, including Manual pairing code and QR code URL.
Open the provided URL in your browser to generate the QR code image, which you will use during the commissioning process.

Pairing information on Serial Monitor. Image by author.

Commissioning with Google Home

To connect your smart lamp to the Google Home app:

  1. Open the Google Home app on your smartphone.
  2. Navigate to Devices > +Add button> Matter-enabled device.
  3. Use the pairing code or QR code to commission the device.

Once the process is complete, the device will appear in the Google Home system, ready for control, and the Serial Monitor will confirm the connection to the Matter network with the message “Matter device is now online”.

Adding a new Matter device to Google Home. Source: Arduino docs.

Hey Google, Turn on the lamp!

After commissioning, you can control the lamp directly through the Google Home app or using voice commands via the Hub. Once added, the device will appear as a Matter On/Off Outlet. Simply rename it to “Lamp” in Google Home to indicate that the connected device is a lamp. Enjoy!

Complete Smart Lamp system. Image by author.
Smart Lamp in action! Video by author.

Wrap-up and Ideas for Enhancement

In this project, we successfully transformed a lamp into a smart device controlled through a Smart Home ecosystem, using the Arduino Nano Matter. Key steps included configuring the device, commissioning it, and connecting it to the Matter network via a hub.

An idea to make this setup even smarter is to add a motion sensor (for example, a PIR sensor), which would allow the lamp to automatically turn on when motion is detected, offering greater energy efficiency.

With the Arduino Nano Matter, retrofitting any device into a smart appliance becomes easy and fast, enabling simple integration with Matter.

For additional resources, please refer to the following links:

--

--

Leonardo Cavagnis
Leonardo Cavagnis

Written by Leonardo Cavagnis

Passionate Embedded Software Engineer, IOT Enthusiast and Open source addicted. Proudly FW Dev @ Arduino

No responses yet