Be Smart, Go Local.

How To Create Thread Devices with ESPHome

Simple guide for creating ESP32-C6 and ESP32-H2 Thread network routers with ESPHome firmware and the OpenThread component.

ESPHome recently released a new OpenThread core component, adding Thread support for ESPHome devices. The purpose of this component is to allow ESPHome nodes to communicate over a Thread network. It permits the state of sensors and binary sensors to be sent to Home Assistant via 6LoWPAN packets.

Guide for Creating ESPHome Thread Devices: Hero Image by SmartHomeScene

This article is a step-by-step guide for flashing compatible ESP32 boards with OpenThread ESPHome firmware. In other words, your nodes will use Thread as a connectivity protocol instead of Wi-Fi and operate as FTDs (Full Thread Devices) or MTDs (Minimal Thread Devices).

Supported ESP Boards

The OpenThread ESPHome component supports the ESP32-C6 and ESP32-H2 boards only. These boards are the only Espressif devices equipped with Thread modules, which can be used with this ESPHome component or Espressif’s own ZeroCode platform.

Guide for Creating ESPHome Thread Devices: ESP32-C6 Board

ESP32-C6

Wi-Fi, Zigbee, Thread, Bluetooth

2xUSB-C

19 GPIOs

ESPHome

Guide for Creating ESPHome Thread Devices: ESP32-H2 Board

ESP32-H2

Zigbee, Thread, Bluetooth

2xUSB-C

19 GPIOs

ESPHome

It’s worth noting that the ESP32-C6 is pricier than the ESP32-H2, but it does support Wi-Fi while the ESP32-H2 doesn’t. The ESP32-H2 supports Thread, Zigbee, and Bluetooth only. Both boards rely on a single-core 32-bit RISC-V with a frequency of up to 96 MHz. Both have 320 KB SRAM, 128 KB ROM, 2 MB Flash and 19 separate GPIOs with ADC, SPI, UART, I2C, I2S, RMT, GDMA and LED PWM support. If you are getting a new board, go for the ESP32-C6.

Considerations and Limitations

It’s worth remembering that Thread is designed as a low-power, low-bandwidth networking protocol. In this regard, it’s very similar to Zigbee as it’s specifically optimized for IoT devices with minimal data transmission needs, battery-powered or energy-efficient applications and mesh networking scenarios.

From an ESPHome device perspective, this simply means that Thread is not suitable for applications requiring high-frequency sensor data transmission. If you are building an ESPHome device that sends large payloads, has many sensors and updates very frequently (e.g. Apollo R PRO-1), you are better of using Wi-Fi.

Furthermore, the OpenThread component in ESPHome supports FTD and MTD devices, but not “Sleepy End Devices” (low-power sleep functionality). At this moment, you will not be able to create a Thread device that utilizes battery power very effectively.

Obtaining Thread Network Info

Before preparing and flashing the ESP board with Thread, you will need to obtain your Thread network info. In my testing instance, I am running the SMLight SLZB-MR1 Dual Radio coordinator with the OpenThread Border Router Add-on. The SLZB-MR1 has two individual antennas that support both Zigbee and Thread.

In Home Assistant, navigate to Settings > Devices & Services > Thread > Configure (cogwheel). Click the small information button in the corner of your preferred network and you will be able to see the network name, channel, pan ID and the active TLV dataset.

Save the network information in a file somewhere for easy copy-pasting. The Thread network information will be added to ESPHome instead of Wi-Fi, making the node communicate over Thread. The TLV dataset configuration is easier and straightforward, so make sure the TLV string is correct when saving.

Flashing the ESP32 with OpenThread

The next step is to create a new ESPHome device and flash it with a basic configuration. The easiest way to do this is to use the ESPHome builder add-on directly in Home Assistant. However, instead of configuring Wi-Fi, we will configure OpenThread directly and connect the node to your existing Thread network.

  • Open the ESPHome Builder Add-on
  • Click + New Device and give it a name
  • Under device type, select your board (e.g. ESP32-C6)
  • At the Install window, click Skip

There is no need to flash the board with the default Wi-Fi-generated configuration first. You can do so if you want to verify the board is working properly, but you can simply add the OpenThread configuration and flash the board directly. Under your newly created device, click the Edit button. Remove the wifi and captive_portal components and paste the following:

network:
  enable_ipv6: true

openthread:
  tlv: 0e080000000000010000000300000f4a0300001535060004001fffe00208705af96415d64a0a0708fd5ca8324cb383c0051061023d547b525edc174a08169bee1809030e68612d7468726561642d653866340102e8f404103e7c0e82c83b1b2b5098e6b2d3c38b820c0402a0f7f8

Replace the tlv string with your own that you saved from your Thread network info. Pasting the TLV will allow ESPHome to automatically extract all data from your network and commission the node automatically. There is no need to manually configure the network, but if you want, you can configure it in this format:

# Example OpenThread component configuration
network:
  enable_ipv6: true

openthread:
  device_type: FTD
  channel: 13
  network_name: OpenThread-8f28
  network_key: 0xdfd34f0f05cad978ec4e32b0413038ff
  pan_id: 0x8f28
  ext_pan_id: 0xd63e8e3e495ebbc3
  pskc: 0xc23a76e98f1a6483639b1ac1271e2e27
  mesh_local_prefix: fd53:145f:ed22:ad81::/64
  force_dataset: true

Save the configuration, click Install and select Manual download. Choose the Factory Format (previously Modern) and save the .bin file somewhere on your computer. Connect your ESP32 via USB, open ESPHome’s Web Flasher, click Connect, select your board, and click Install. Select the firmware file and wait for the process to finish. Done!

Connecting the Thread node

Once the node reboots, it will automatically connect to your configured Thread network. At the moment, there isn’t an obvious way to verify the node is using Thread instead of Wi-Fi. Since Thread is just a communication protocol, an application layer like Matter or ESPHome’s API is needed to actually interact with the device.

Guide for Creating ESPHome Thread Devices: Auto-discovered in Home Assistant

When the Thread device boots back up, it will get auto-discovered in Home Assistant, just like a regular ESPHome device. You would expect it will appear as a new Thread device, but since it’s added via the ESPHome API, it appears as regular ESPHome device. You simply click Add to add it to Home Assistant.

If you navigate to the ESPHome Builder, select your device and click Logs, you will be able to see the device is using OpenThread. As there isn’t a Wi-Fi configuration added at all, the device is connected via an IPV6 address to your existing Thread network.

Guide for Creating ESPHome Thread Devices: ESPHome Logs
ESP32-C6 Thread node ESPHome logs

Checking Thread network topology

ESPHome allows you create several text sensors, exposing the state of your OpenThread nodes. By adding these to your device configuration in the builder, the network information will be exposed to Home Assistant. Please note, wireless flashing is much slower over Thread compared to Wi-Fi, so be patient.

text_sensor:
  - platform: openthread_info
    ip_address:
      name: "IP Address"
    channel:
      name: "Channel"
    role:
      name: "Device Role"
    rloc16:
      name: "RLOC16"
    ext_addr:
      name: "Extended Address"
    eui64:
      name: "EUI64 Interface ID"
    network_name:
      name: "Network Name"
    network_key:
      name: "Network Key"
    pan_id:
      name: "PAN ID"
    ext_pan_id:
      name: "Extended PAN ID"

Once the device reboots, the new sensors will be added to Home Assistant:

Guide for Creating ESPHome Thread Devices: Added to Home Assistant
ESP32-C6 Thread node added to Home Assistant

Now, to truly verify the connection, I removed any existing Thread devices from this testing network. I left only the border router and my new ESPHome thread sensor. The OTBR Add-on allows you to access the network topology once you expose a web port and access the UI. This is disabled by default and you can enable it as follows in Home Assistant:

  • Navigate to Settings > Add-ons
  • Click OpenThread Border Router Add-on
  • Click Configuration at the top
  • Scroll down to Network and set the two ports:
    • OpenThread Web port: 8080
    • OpenThread REST API port: 8081
    • Change them to something else if these are already taken
  • Click Save and restart the Add-on

With the port exposed, access the OpenThread Add-on interface with your local Home Assistant IP address followed by the OTBR web port (e.g. 192.168.0.220:8080). On the left side of the menu, click Topology and let the map load. In my case, I should see only my SLZB-MR1 border router and new Thread Sensor:

Guide for Creating ESPHome Thread Devices: Network Topology
OpenThread Network Topology

Selecting the new Thread Sensor and comparing the data to the Home Assistant sensors verifies the device is connected and working properly with OpenThread. As my node is configured as a FTD (Full Thread Device), it operates as a Router. It will relay traffic from neighboring devices back to the Border Router, solidifying and extending my mesh network.

Final Thoughts

The addition of OpenThread support to ESPHome is a great development. The supported ESP32-C6 [Amazon, AliExpress] and ESP32-H2 [Amazon, AliExpress] boards are a very affordable way to build out your Thread network, especially when compared to commercial Thread routers. By strategically placing these low-cost boards around your home, you can easily strengthen and expand your Thread mesh network.

The great thing is you can freely turn them into any kind of DIY smart device, attaching sensors or peripherals like you normally would with ESPHome Wi-Fi devices. For example, you can turn them into soil sensors, mmWave radar sensors or temperature probe sensors.

However, it is important to remember that Thread is a low-bandwidth protocol. It is designed for small, infrequent data transmissions, not large data payloads. If you plan on building a data-heavy or sensor-rich device that needs to send a lot of information, a Wi-Fi connection would be a much better choice.

Do you have any ideas or suggestions? Let me know below.

Leave a Comment