Smart-home gadgets used to need a separate app and cloud for every brand. Matter fixes that: one device works with Google Home, Apple Home, Amazon Alexa and Home Assistant, and it is controlled locally on your network. In this ESP32-C6 Matter tutorial you will build a real Matter smart light with the Arduino IDE, pair it using a QR code, and control it from your phone or by voice. It is a good base for a final-year project or a product prototype.

Table of Contents
What is Matter (in 60 seconds)?
- An application standard over IP. Matter devices talk over Wi-Fi, Thread or Ethernet using normal IPv6 networking.
- Bluetooth LE for setup. A new device advertises over BLE. Your phone scans its QR code and sends it the network credentials. This step is called commissioning.
- Local control. After commissioning, the controller (Home Assistant, a Nest hub, an Echo, a HomePod…) talks to the device directly on your LAN.
- Multi-admin. One device can join several ecosystems at the same time.

Why use the ESP32-C6 for Matter?
Matter is maintained by the Connectivity Standards Alliance (CSA), the same group behind Zigbee. Apple, Google, Amazon, Samsung and hundreds of other companies back it.
The ESP32-C6 combines Wi-Fi 6, Bluetooth LE and an IEEE 802.15.4 radio (used by Thread and Zigbee) on one low-cost chip. That covers BLE commissioning, Matter over Wi-Fi and Matter over Thread. Here is how it compares with other Espressif chips:
| Chip | Wi-Fi | Thread (802.15.4) | BLE commissioning | Good for |
|---|---|---|---|---|
| ESP32-C6 | Wi-Fi 6 (2.4 GHz) | Yes | Yes | Best all-round Matter learning chip |
| ESP32-H2 | No | Yes | Yes | Battery-powered Thread sensors |
| ESP32-C5 | Dual-band Wi-Fi 6 | Yes | Yes | Newer; dual-band Wi-Fi products |
| ESP32-S3 / C3 / classic ESP32 | Yes | No | S3/C3 yes | Matter over Wi-Fi only |
Espressif’s Arduino Matter documentation lists the supported chips. On the ESP32-C6 it uses BLE commissioning, so you do not even put your Wi-Fi password in the code: the phone sends it during pairing.
What you need
- ESP32-C6-DevKitC-1 (or any ESP32-C6 board). It has an addressable RGB LED (on GPIO8) and a BOOT button (GPIO9), so this first project needs no extra parts.
- USB-C data cable.
- A 2.4 GHz Wi-Fi network. Matter devices need IPv6 on the LAN; most home routers have it.
- A Matter controller: Home Assistant with its Matter integration (easiest for development), or Google Home with a Nest hub, Apple Home with a HomePod/Apple TV, or Alexa with an Echo.
- A phone with Bluetooth for commissioning.
Note on test devices: your DIY device uses Espressif’s test credentials and is not certified. Home Assistant accepts it directly. Commercial ecosystems may ask you to confirm you are adding an uncertified device, and Google requires the test device to be registered in its developer console first.
Arduino IDE setup

- Install Arduino IDE 2.x.
- In Boards Manager, install esp32 by Espressif Systems, version 3.1 or newer. The Matter library is built in from 3.1.0; use the latest stable release.
- Select Tools → Board → ESP32C6 Dev Module.
- Select the Matter partition scheme: Tools → Partition Scheme → “Matter 4 MB with spiffs” on recent cores. On older 3.x cores choose “Huge APP (3MB No OTA/1MB SPIFFS)”. Matter firmware is large and does not fit the default partitions.
- Enable Tools → Erase All Flash Before Sketch Upload for the first upload. It clears old Wi-Fi and Matter data.
- Open Tools → USB CDC On Boot → Enabled if your Serial Monitor stays empty on the USB port.
The ESP32-C6 Matter smart light sketch
This sketch creates one Matter On/Off Light endpoint, drives the on-board RGB LED, remembers the last state across power cuts, toggles with a short press of BOOT and factory-resets (decommissions) on a 5-second press.
#include <Matter.h>
#include <Preferences.h>
// ---- Hardware (ESP32-C6-DevKitC-1) ----
const uint8_t BUTTON_PIN = 9; // BOOT button, active LOW
const uint32_t DECOMMISSION_MS = 5000; // hold 5 s to factory-reset Matter
MatterOnOffLight light; // one Matter endpoint
Preferences prefs;
// Called by Matter when the state changes (app, voice or button)
bool onLightChange(bool on) {
Serial.printf("Light -> %s\r\n", on ? "ON" : "OFF");
#ifdef RGB_BUILTIN
uint8_t v = on ? 64 : 0; // 64/255 brightness = comfortable to look at
rgbLedWrite(RGB_BUILTIN, v, v, v);
#endif
prefs.putBool("on", on); // survive power cuts
return true; // tell Matter the change succeeded
}
void setup() {
Serial.begin(115200);
pinMode(BUTTON_PIN, INPUT_PULLUP);
prefs.begin("light", false);
bool lastState = prefs.getBool("on", false);
light.begin(lastState); // create endpoint with saved state
light.onChange(onLightChange);
Matter.begin(); // start Matter AFTER endpoints exist
if (!Matter.isDeviceCommissioned()) {
Serial.println("Not commissioned. Pair it with:");
Serial.printf("Manual code: %s\r\n", Matter.getManualPairingCode().c_str());
Serial.printf("QR code URL: %s\r\n", Matter.getOnboardingQRCodeUrl().c_str());
}
light.updateAccessory(); // apply the saved state to the LED
}
void loop() {
static uint32_t pressedAt = 0;
static bool pressed = false;
bool down = (digitalRead(BUTTON_PIN) == LOW);
if (down && !pressed) { // button just pressed
pressed = true;
pressedAt = millis();
}
if (pressed && down && millis() - pressedAt > DECOMMISSION_MS) {
Serial.println("Decommissioning... pair again after reboot.");
light.setOnOff(false);
Matter.decommission(); // erases fabrics, ready to pair again
while (digitalRead(BUTTON_PIN) == LOW) delay(10); // wait for release
pressed = false;
}
if (!down && pressed) { // released before 5 s = toggle
pressed = false;
if (millis() - pressedAt > 50) { // 50 ms debounce
light.toggle();
}
}
delay(10);
}
The API used here (begin(), onChange(), toggle(), setOnOff(), updateAccessory()) is documented on Espressif’s MatterOnOffLight reference page. Newer cores also include button and Wi-Fi helper functions; the plain version above works on older 3.x cores too.
Key points:
Matter.begin()must come after all endpoints are created withbegin().- The callback must return
true; if it returnsfalse, the controller is told the command failed. light.toggle()from the button also reports the new state to every connected ecosystem, so your phone app stays in sync.- To control a real lamp, replace
rgbLedWrite()withdigitalWrite()to a relay or MOSFET driver. Use proper isolation and an enclosure for 230 V loads.
Want to drive a relay safely? Our smart home relay module guide and Wi-Fi relay tutorial show the driver circuit.
Pair the light with your smart-home app
- Upload the sketch and open the Serial Monitor at 115200 baud. Copy the QR code URL into a browser to show the QR code, or note the 11-digit manual pairing code.
- Home Assistant: install the Matter integration, then in the Companion app go to Settings → Devices & services → Add device → Add Matter device, and scan the QR code.
- Google Home / Alexa / Apple Home: Add device → Matter, then scan the QR code. Confirm when asked about an uncertified device.
- The phone talks to the ESP32-C6 over BLE, sends your Wi-Fi details, and the light appears in the app. Toggle it, and try a voice command.
- To add a second ecosystem later, use the app’s Share device / Linked Matter apps option. You do not need to reset.
Troubleshooting common ESP32-C6 Matter problems
| Problem | Likely cause | Fix |
|---|---|---|
| Sketch too big / doesn’t fit | Default partition scheme | Select the Matter or Huge APP partition scheme |
| App can’t find the device | Already commissioned, or Bluetooth off on phone | Hold BOOT 5 s to decommission, or erase flash and re-upload; turn on phone Bluetooth and location |
| Pairing fails at ‘connecting to network’ | 5 GHz-only Wi-Fi, or IPv6 blocked on router | Use a 2.4 GHz SSID; enable IPv6 on the LAN |
| Works, then goes ‘unavailable’ | Weak Wi-Fi or router client isolation | Move closer, disable AP isolation, give the board a stable power supply |
| Serial Monitor shows nothing | USB CDC disabled | Enable USB CDC On Boot, or use the UART port |
Shipping it as a product? Read our IoT security best practices. A battery-powered version will also need the ideas in our low-power IoT design guide.
Frequently asked questions
Does the ESP32-C6 Matter light need internet?
No. Matter control is local. Internet is only needed if you want remote access or voice assistants that process speech in the cloud.
Can I use Matter over Thread instead of Wi-Fi?
Yes. The ESP32-C6 has a Thread radio, and recent Arduino cores add Thread support for it (otherwise use the ESP-IDF Matter examples). You also need a Thread border router, such as many Nest, Apple TV/HomePod or Home Assistant setups.
Can a classic ESP32 or ESP32-S3 do Matter?
Yes, Matter over Wi-Fi works on them too. The C6 is recommended because it adds Thread and Wi-Fi 6 at a similar price.
Can I sell a product built like this?
Not with the test credentials. Commercial Matter products need a vendor ID, certification and unique device attestation certificates. Use this tutorial for learning and prototypes.
Is this a good final-year project?
Yes, especially if you add sensors (energy metering, temperature) and multiple endpoints. See our final-year project ideas and ESP32 beginner projects for more.
Conclusion
With an ESP32-C6, the Arduino IDE and about 60 lines of code you now have a standards-based smart light that works with every major ecosystem, with no custom app and no cloud. Ready to make a custom board for it? Follow our KiCad 10 to JLCPCB guide. Next, add a relay for a real lamp, a dimmable or colour light endpoint, or a sensor endpoint, and you have the core of a serious IoT product.
Need a custom Matter / IoT device, PCB or final-year project? We design custom PCBs, firmware and complete working prototypes for students and companies. Message us on WhatsApp or use the contact form. You can write in Bangla or English.
0 Comments