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.

ESP32-C6 Matter tutorial cover: build a smart light with Arduino
ESP32-C6 Matter: one device, every smart-home ecosystem

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.
ESP32-C6 Matter commissioning flow: phone app over BLE, Wi-Fi or Thread network, controller hub
How an ESP32-C6 Matter device joins your home network

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:

ChipWi-FiThread (802.15.4)BLE commissioningGood for
ESP32-C6Wi-Fi 6 (2.4 GHz)YesYesBest all-round Matter learning chip
ESP32-H2NoYesYesBattery-powered Thread sensors
ESP32-C5Dual-band Wi-Fi 6YesYesNewer; dual-band Wi-Fi products
ESP32-S3 / C3 / classic ESP32YesNoS3/C3 yesMatter 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

ESP32-C6 Matter tutorial build steps in Arduino IDE
Eight steps from install to a working Matter light
  1. Install Arduino IDE 2.x.
  2. 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.
  3. Select Tools → Board → ESP32C6 Dev Module.
  4. 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.
  5. Enable Tools → Erase All Flash Before Sketch Upload for the first upload. It clears old Wi-Fi and Matter data.
  6. 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 with begin().
  • The callback must return true; if it returns false, 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() with digitalWrite() 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

  1. 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.
  2. 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.
  3. Google Home / Alexa / Apple Home: Add device → Matter, then scan the QR code. Confirm when asked about an uncertified device.
  4. 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.
  5. 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

ProblemLikely causeFix
Sketch too big / doesn’t fitDefault partition schemeSelect the Matter or Huge APP partition scheme
App can’t find the deviceAlready commissioned, or Bluetooth off on phoneHold 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 routerUse a 2.4 GHz SSID; enable IPv6 on the LAN
Works, then goes ‘unavailable’Weak Wi-Fi or router client isolationMove closer, disable AP isolation, give the board a stable power supply
Serial Monitor shows nothingUSB CDC disabledEnable 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.


MKDas

Mithun K. Das. B.Sc. in Electrical and Electronic Engineering (EEE) from KUET. Senior Embedded Systems Designer at a leading international company. Welcome to my personal blog! I share articles on various electronics topics, breaking them down into simple and easy-to-understand explanations, especially for beginners. My goal is to make learning electronics accessible and enjoyable for everyone. If you have any questions or need further assistance, feel free to reach out through the Contact Us page. Thank you for visiting, and happy learning!

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *