Project

Matter-over-Wi-Fi dimmable light on the ESP32-C5

A Matter dimmable light on the ESP32-C5 built with the esp_matter 1.6.1 component in ESP-IDF v6.1.1, commissioned from Home Assistant or chip-tool with the public test credentials. Low-voltage LED only.

IntermediateEspressifTier 1: Builds in CIUpdated 28 November 2026
BoardEspressif ESP32-C5-DevKitC-1 v1.2
Timeabout 3 hours
Stackesp-idf, cpp, home-assistant
Extra partsESP32-C5-DevKitC-1 v1.2, LED and series resistor, Push button (optional, the board's Boot button works)

This project turns an ESP32-C5-DevKitC-1 into a Matter dimmable light that joins your Wi-Fi network and is controlled from Home Assistant or from chip-tool. It is for makers who want a first Matter device they built themselves, and for product teams who need to know which esp-matter release and ESP-IDF version actually build for the ESP32-C5 today. The light is one low-voltage LED driven by a GPIO (general-purpose input/output) pin. Nothing in this project switches mains power.

What you will build

  • A Matter node with a Dimmable Light endpoint (On/Off and Level Control clusters) on an ESP32-C5, written against the esp_matter 1.6.1 component.
  • LEDC (LED control peripheral) PWM (pulse-width modulation) on GPIO23 that follows the light’s on/off state and level.
  • Local control: a short press on the Boot button (GPIO28) toggles the light. Holding it for 10 s erases the Matter fabric data so you can commission again.
  • Commissioning over Bluetooth LE onto Wi-Fi, with the public Matter test credentials, from the Home Assistant Companion app or chip-tool.
  • A Home Assistant automation that turns the light on before sunset.

Which esp-matter supports the ESP32-C5

Before writing code we checked Espressif’s own documents on 28 November 2026.

  • There are no release tags. The esp-matter repository publishes releases as branches (release/v1.0 to release/v1.6.1) and has no git tags. The README maps release/v1.6.1 to Matter specification v1.6.1, and main to v1.7, still in progress.
  • The ESP32-C5 is a documented target in the release/v1.6.1 programming guide, with idf.py set-target esp32c5. Because the C5 has both Wi-Fi and an 802.15.4 radio, the guide tells you to choose one: for Wi-Fi set CONFIG_OPENTHREAD_ENABLED=n, CONFIG_ENABLE_WIFI_STATION=y and CONFIG_USE_MINIMAL_MDNS=y.
  • The recommended ESP-IDF is v6.0.2, not v6.1.1. The release/v1.6.1 README recommends ESP-IDF v6.0.2 and connectedhomeip commit 0998b87db7, and the branch’s CI is configured with ESP-IDF v6.0.2. On the older release/v1.5 branch the README recommended ESP-IDF v5.5.5 for the ESP32-C5.
  • The component route. The same SDK is published on the Espressif Component Registry as espressif/esp_matter. Version 1.6.1 appeared on 23 October 2026. A project adds it in idf_component.yml and needs no esp-matter clone, no connectedhomeip submodules and no host tools.

What we tried: this project uses the component, pinned to 1.6.1, and builds in the same espressif/idf:v6.1.1 Docker image as every other example on this site. The build passes for esp32c5 (tier 1, details under Test). That is our build result for a combination Espressif does not list. For a product, use the combination the README recommends (ESP-IDF v6.0.2 with release/v1.6.1) until Espressif lists v6.1.

What you need

Part Why Reference
ESP32-C5-DevKitC-1 v1.2 ESP32-C5-WROOM-1 module, 8 MB flash and 8 MB PSRAM on the N8R8 variant User guide
One LED and a series resistor The light. Size the resistor for your LED so the current stays at a few milliamps ESP32-C5 datasheet v1.5, Table 5-4
Phone with the Home Assistant Companion app, or a Linux or macOS host with chip-tool Commissioner Matter integration
Home Assistant with the Matter integration (optional) Controller and automations Same page

Wire the LED’s anode through the resistor to GPIO23 (header J3 pin 5) and its cathode to GND. GPIO23 is not a strapping pin on this board. The ESP32-C5 datasheet gives a typical high-level source current of 40 mA at 3.3 V with the strongest drive setting. That is a typical figure, not a rating to design to, so keep the LED current far below it. The Boot button is SW1 on GPIO28 in the v1.2 schematic, and the firmware reads it with the internal pull-up enabled.

Design

Phone (Companionapp) or chip-toolHome Assistant +Matter ServerWi-Fi APESP32-C5esp_matter 1.6.1Dimmable Lightendpoint 1LEDButton1. Bluetooth LE: passcode, attestation, Wi-Fi credentials2. IPv6 over Wi-Fi: On/Off and Level Control commandsPWMGPIO28
Commissioning and control paths. The commissioner sends Wi-Fi credentials over Bluetooth LE, then Home Assistant or chip-tool controls the light over IPv6 on the Wi-Fi network. The firmware drives the LED with LEDC PWM. Drawn from the esp-matter release/v1.6.1 programming guide.

Commissioning a Matter Wi-Fi device happens in two stages, as the chip-tool pairing ble-wifi command in the esp-matter guide shows. First the commissioner reaches the device over Bluetooth LE, proves it knows the setup passcode, checks the device’s attestation credentials and hands over the Wi-Fi network name and password. Then the device joins Wi-Fi, and from that point the controller talks to it over IPv6 on the local network. This is why Home Assistant’s documentation asks for IPv6 multicast to reach the Home Assistant host, and for the device, the phone and Home Assistant to share one network segment.

The firmware has three parts. app_main() creates the node and the endpoint and starts Matter. The attribute callback runs before each attribute change is stored (PRE_UPDATE) and moves the LED to match. A small task polls the button and writes the On/Off attribute through attribute::update(), so a local press is reported to every controller like any other change.

Development attestation only

Every Matter device proves its origin with a DAC (device attestation certificate), signed by a PAI (product attestation intermediate). The esp-matter option “Attestation - Test” (CONFIG_EXAMPLE_DAC_PROVIDER) compiles in the test DAC that the Matter SDK publishes. The test commissioning values are vendor ID 0xFFF1, product ID 0x8000, discriminator 3840 and passcode 20202021. Our sdkconfig.defaults sets those options explicitly so nobody mistakes the build for a production one. Never put other certificates or keys in this repository or in your own fork.

Firmware

The firmware is in examples/c5-matter-wifi-light/firmware/. The dependency is one pinned line, and dependencies.lock records everything the component manager resolved:

dependencies:
  espressif/esp_matter:
    version: "1.6.1"
  idf:
    version: ">=6.0"

The LED and the attribute callback:

// target: esp32c5 sdk: esp-idf v6.1.1 + esp_matter 1.6.1 tier: 1
// ...
static void led_init(void)
{
    ledc_timer_config_t t = {};
    t.speed_mode = LEDC_LOW_SPEED_MODE;
    t.duty_resolution = PWM_BITS;
    t.timer_num = LEDC_TIMER_0;
    t.freq_hz = 1000;
    t.clk_cfg = LEDC_AUTO_CLK;
    ESP_ERROR_CHECK(ledc_timer_config(&t));

    ledc_channel_config_t c = {};
    c.gpio_num = LED_GPIO;
    c.speed_mode = LEDC_LOW_SPEED_MODE;
    c.channel = LEDC_CHANNEL_0;
    c.timer_sel = LEDC_TIMER_0;
    c.duty = 0;
    ESP_ERROR_CHECK(ledc_channel_config(&c));
}

static void led_apply(void)
{
    uint32_t duty = s_on ? (uint32_t)s_level * PWM_MAX / 254 : 0;
    ledc_set_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0, duty);
    ledc_update_duty(LEDC_LOW_SPEED_MODE, LEDC_CHANNEL_0);
    ESP_LOGI(TAG, "light %s level %u duty %lu", s_on ? "on" : "off", s_level, (unsigned long)duty);
}

// Called for every attribute write. PRE_UPDATE lets the hardware follow before the value is stored.
static esp_err_t on_attribute(callback_type_t type, uint16_t ep, uint32_t cluster, uint32_t attr,
                              esp_matter_attr_val_t *val, void *)
{
    if (type != PRE_UPDATE || ep != s_light_ep) {
        return ESP_OK;
    }
    if (cluster == OnOff::Id && attr == OnOff::Attributes::OnOff::Id) {
        s_on = val->val.b;
        led_apply();
    } else if (cluster == LevelControl::Id && attr == LevelControl::Attributes::CurrentLevel::Id) {
        s_level = val->val.u8;
        led_apply();
    }
    return ESP_OK;
}

The button task. attribute::update() must run with the Matter stack locked, because the button task is not the Matter task:

// target: esp32c5 sdk: esp-idf v6.1.1 + esp_matter 1.6.1 tier: 1
// ...
static void button_task(void *)
{
    gpio_config_t io = {};
    io.pin_bit_mask = 1ULL << BUTTON_GPIO;
    io.mode = GPIO_MODE_INPUT;
    io.pull_up_en = GPIO_PULLUP_ENABLE;
    gpio_config(&io);
    int held_ms = 0;
    for (;;) {
        vTaskDelay(pdMS_TO_TICKS(20));
        if (gpio_get_level(BUTTON_GPIO) == 0) {
            held_ms += 20;
            if (held_ms == 10000) {
                ESP_LOGW(TAG, "factory reset");
                esp_matter::factory_reset();
            }
            continue;
        }
        if (held_ms >= 50 && held_ms < 10000) {
            esp_matter_attr_val_t v = esp_matter_bool(!s_on);
            chip::DeviceLayer::PlatformMgr().LockChipStack();
            attribute::update(s_light_ep, OnOff::Id, OnOff::Attributes::OnOff::Id, &v);
            chip::DeviceLayer::PlatformMgr().UnlockChipStack();
        }
        held_ms = 0;
    }
}

extern "C" void app_main(void)
{
    ESP_ERROR_CHECK(nvs_flash_init());
    led_init();

    node::config_t node_config;
    node_t *node = node::create(&node_config, on_attribute, on_identify);
    if (node == nullptr) {
        ESP_LOGE(TAG, "node create failed");
        return;
    }

    dimmable_light::config_t light_config;
    light_config.on_off.on_off = false;
    light_config.level_control.current_level = s_level;
    light_config.level_control.on_level = s_level;
    endpoint_t *ep = dimmable_light::create(node, &light_config, ENDPOINT_FLAG_NONE, nullptr);
    if (ep == nullptr) {
        ESP_LOGE(TAG, "endpoint create failed");
        return;
    }
    s_light_ep = endpoint::get_id(ep);
    ESP_LOGI(TAG, "dimmable light on endpoint %u", s_light_ep);

    ESP_ERROR_CHECK(esp_matter::start(on_event));
    led_apply();
    xTaskCreate(button_task, "button", 3072, nullptr, 5, nullptr);
}

The settings that matter most, from sdkconfig.defaults. The rest are copied from esp-matter’s managed_component_light example, as is the partition table with two OTA (over-the-air update) slots of 0x1E0000 bytes in 4 MB of flash:

# Based on esp-matter release/v1.6.1 examples/managed_component_light/sdkconfig.defaults
// ...
# Wi-Fi, not Thread (esp-matter developing guide, ESP32-C5 section)
CONFIG_OPENTHREAD_ENABLED=n
CONFIG_ENABLE_WIFI_STATION=y
CONFIG_USE_MINIMAL_MDNS=y
# Development attestation only: the public test DAC/PAI/CD compiled into connectedhomeip
# ("Attestation - Test") and the public test passcode 20202021 / discriminator 3840.
CONFIG_EXAMPLE_DAC_PROVIDER=y
CONFIG_EXAMPLE_COMMISSIONABLE_DATA_PROVIDER=y
CONFIG_ENABLE_TEST_SETUP_PARAMS=y

Back end

Home Assistant. Add the Matter integration, which installs the Matter Server app on Home Assistant OS. In the Companion app go to Settings, Connectivity, Matter, Add device, and choose “No. It’s new.”. Scan the QR code MT:Y.K9042C00KA0648G00 or type the manual code 34970112332. Both encode the test values above. Home Assistant’s documentation says iOS may warn about an uncertified accessory for a test board, where you choose Add Anyway. On Android, test devices may need extra steps in the Google Developer console, and commissioning fails without them. Then add an automation:

# Home Assistant automation for the Matter light once it is commissioned.
# Replace light.fg_matter_light with the entity id Home Assistant gives the light.
automation:
  - alias: "Field Guide light on before sunset"
    triggers:
      - trigger: sun
        event: sunset
        offset: "-00:30:00"
    actions:
      - action: light.turn_on
        target:
          entity_id: light.fg_matter_light

chip-tool. The esp-matter guide gives these commands. Keep the Wi-Fi name and password in your shell environment:

#!/bin/sh
# snippet: chip-tool commands from the esp-matter guide (release/v1.6.1), test credentials only.
# Commission over BLE onto Wi-Fi, then control endpoint 1. Node id 0x7283 is arbitrary.
# WIFI_SSID and WIFI_PASS come from your shell environment, never from this file.
chip-tool pairing ble-wifi 0x7283 "$WIFI_SSID" "$WIFI_PASS" 20202021 3840
chip-tool onoff toggle 0x7283 0x1
chip-tool levelcontrol move-to-level 100 0 0 0 0x7283 0x1

Enclosure

Use the wall and DIN-rail mount. It is a carrier for the ESP32-C5-DevKitC-1 v1.2 that clips onto a 35 mm top-hat rail or screws to a wall, with the antenna end pointing up. Mounting it on a rail does not make this a mains device. The board is powered from its USB-C port by a certified 5 V supply, and the only load is the LED. Do not place it in a cabinet next to mains wiring.

Build and flash

cd examples/c5-matter-wifi-light/firmware
idf.py set-target esp32c5
idf.py build
idf.py -p <port> erase-flash flash monitor

The esp-matter guide recommends erasing the flash before the first flash. The first build downloads the component and its dependencies, and compiling the Matter stack takes several minutes.

Test

After a fresh flash, before commissioning, the console shows the endpoint and the LED off at the default level:

I (<ms>) fg_light: dimmable light on endpoint 1
I (<ms>) fg_light: light off level 64 duty 0

During commissioning you should see “commissioning complete”. After that chip-tool onoff toggle or the Home Assistant tile lights the LED, and the log prints the new level and duty cycle. A short press on Boot does the same, and Home Assistant shows the change.

  • Tier 1 (builds in CI): passes. tools/ci/check_example.py builds firmware/ for esp32c5 with espressif/esp_matter 1.6.1 in espressif/idf:v6.1.1. The application image is 1,811,456 bytes in a 1,966,080-byte OTA slot. The Home Assistant automation is checked as YAML.
  • Tier 2: not applicable. There is no host-side logic to run without the radio.
  • Tier 3 (tested on hardware): waiting for the owner’s bench run on an ESP32-C5-DevKitC-1 v1.2:
python tools/bench/bench.py flash --port <port> --example c5-matter-wifi-light --target esp32c5
python tools/bench/bench.py capture --port <port> --seconds 15 --reset --expect examples/c5-matter-wifi-light/bench/expect.txt --board-rev "ESP32-C5-DevKitC-1 v1.2" --example c5-matter-wifi-light --target esp32c5

The bench runner checks the boot log only. Commissioning with chip-tool or Home Assistant and toggling the light are manual steps for the same session, and the page will say so when they are recorded.

For makers

Use the component route and Home Assistant. Keep the phone, Home Assistant and the board on the same 2.4 GHz network for commissioning, and check that your router does not filter IPv6 multicast. If commissioning stalls, erase the flash and try again before changing code.

For product teams

The test DAC makes this a development build. A product needs its own DAC and PAI chained to a PAA (product attestation authority) that commissioners trust, a certification declaration (CD), commissioning data per unit generated with esp-matter-mfg-tool, and Matter certification through the Connectivity Standards Alliance. Espressif offers pre-provisioned modules and certification assistance, according to the esp-matter README. Build on the IDF version Espressif recommends for your esp-matter branch (v6.0.2 for release/v1.6.1 today), and track the release notes, which list breaking API changes between branches.

Things to try

  • Thread instead of Wi-Fi. The ESP32-C5 has an 802.15.4 radio. The esp-matter guide’s Thread settings are the reverse of the Wi-Fi ones (CONFIG_OPENTHREAD_ENABLED=y, CONFIG_ENABLE_WIFI_STATION=n, CONFIG_USE_MINIMAL_MDNS=n), and you need a Thread border router, as in the Thread sensor project.
  • Colour. The board’s RGB LED is on GPIO27. Change the endpoint to extended_color_light and drive it with the led_strip component.
  • OTA updates. esp-matter’s example enables the OTA requestor. Add CONFIG_ENABLE_OTA_REQUESTOR=y and test an update from an OTA provider on your bench.
  • Factory data. Generate a factory partition with esp-matter-mfg-tool and your own test vendor values to see how production credentials replace the built-in ones.

Summary

  • esp-matter ships releases as branches, and release/v1.6.1 documents the ESP32-C5 for Wi-Fi or Thread, with ESP-IDF v6.0.2 recommended.
  • The espressif/esp_matter 1.6.1 component builds for the ESP32-C5 in ESP-IDF v6.1.1 without cloning esp-matter. That is our CI result, not a combination Espressif lists.
  • The firmware is one dimmable light endpoint, a PWM LED and a local button, using only the public test attestation and passcode.
  • Commission from Home Assistant or chip-tool. Tier 3 waits for the owner’s bench run and a manual commissioning test.