ESP32/Other radios/66. Zigbee, Thread and Matter
Your chip
Your language
Not on your chip
The ESP32-S3 cannot do this.

Nothing on this page will run on a bare S3. The page below is unchanged — read it if you are planning ahead or using a different board.

Other radios · 66 of 81

Zigbee, Thread and Matter

The C6 and H2 have a second radio that is not Wi-Fi and not Bluetooth. It does something neither can - messages hop from device to device - and it is what gets a homemade sensor into Apple Home without an app.

/esp32/zigbee-thread-and-matter · arduino · S3

Why a mesh needs a wall socket

1 coordinator, 2 routers, the rest on batteries
43 m across
Mains-powered routers2
What your board is
Network reaches
43 m
Your node draws
30 µA
Battery viable
yes
30 µA average, because it sleeps and its parent holds messages for it. That is the trade Thread and Zigbee make and Wi-Fi cannot: years on a coin cell, at the cost of never being the one that forwards. And the reason to care about Matter specifically is that it is the layer that gets the device into Apple Home and Google Home without an app of your own.

The three words, untangled

  • 802.15.4 — the radio. Low power, low rate, 2.4 GHz, built for hopping.
  • Zigbee and Thread — two networking layers on that radio. Thread carries IP addresses, which is why it is the one with a future.
  • Matter — the application layer above either, plus Wi-Fi. Matter is what makes a device appear in Apple Home, Google Home and Alexa without an app of your own.

What you need in the house

A border router — an Apple TV, a HomePod, a Nest hub, or an ESP32 running one — bridges the 802.15.4 network to your Wi-Fi. Without one, a Thread device has nothing to talk to.

When to use it instead of Wi-Fi

When the device runs on a coin cell and must be reachable at any moment. Everything else — a mains sensor, a display, anything sending more than a few bytes — is simpler over Wi-Fi and MQTT.

On your S3
ChipXtensa LX7 · 2 × 240 MHz
Board settingESP32S3 Dev Module
Default I2CSDA 8 · SCL 9
Watch out forThe port vanishes after upload

The code

The Arduino Zigbee library wraps a great deal of machinery. What you write is the device type and the value - joining, routing and rejoining are handled below you.

zigbee_sensor.ino
#include "Zigbee.h"

ZigbeeTempSensor sensor(10);       // endpoint number

void setup() {
  Serial.begin(115200);

  sensor.setManufacturerAndModel("Lonely Binary", "Greenhouse");
  sensor.setMinMaxValue(-20, 60);
  Zigbee.addEndpoint(&sensor);

  // END_DEVICE sleeps. ROUTER stays awake and forwards for others.
  if (!Zigbee.begin(ZIGBEE_END_DEVICE)) {
    Serial.println("failed to start");
    return;
  }
  while (!Zigbee.connected()) delay(100);
}

void loop() {
  sensor.setTemperature(21.4);
  sensor.report();
  delay(60000);
}

Select the Zigbee end-device partition scheme in the IDE, or it will not fit. This is the one place where a menu you have never opened decides whether the sketch compiles.

When it does not work

The device joins and drops off after a few minutes

It joined as an end device with no router in range, or the parent it chose has gone. A mesh needs mains-powered nodes to relay - a network of battery devices is not a mesh.

Commissioning into Apple Home fails

Matter needs a border router on the network - a HomePod, an Apple TV, or a Google Nest hub. Without one there is nothing to bridge Thread to your Wi-Fi.

The sketch does not fit

Choose the Zigbee partition scheme in Tools. The stack plus the certificates does not fit the default layout.

My S3 or classic ESP32 cannot do this

Correct - they have no 802.15.4 radio. Among the chips here it is the C6, plus the H2 which has the radio and no Wi-Fi.

Where this goes next

A mesh covers a house. The next page covers a valley, at the cost of almost all the bandwidth.

LoRa for long range

Edit this page — content/esp32/zigbee-thread-and-matter.mdx

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse ESP32 on the forum