Smart Home AssistantNewsletter

ESPHome for Home Assistant: A Beginner's Guide

SepehrBy Sepehr· 19/06/2026· 6 min read
ESPHome for Home Assistant: A Beginner's Guide

ESPHome is one of the most powerful tools in any Home Assistant user's kit. It takes an inexpensive ESP32 or ESP8266 microcontroller — boards that cost between £2 and £10 from UK electronics suppliers — and turns it into a fully integrated smart home device. You describe what the hardware should do in a simple YAML file, ESPHome compiles the firmware, flashes it over USB or Wi-Fi, and the device appears automatically in Home Assistant. No programming experience needed.

Whether you want a room temperature sensor, a custom motion detector, addressable LED strips, or even a DIY soil moisture monitor for the garden, ESPHome handles the heavy lifting. This guide covers everything you need to get started: installing the add-on, writing your first configuration, flashing your first board, and wiring it into automations.

What Is ESPHome?

ESPHome is an open-source firmware framework maintained by Nabu Casa, the company behind Home Assistant. It targets Espressif's popular ESP8266 and ESP32 families of Wi-Fi microcontrollers, along with newer chips including the ESP32-S2, ESP32-S3, ESP32-C3, ESP32-C6, and ESP32-H2. The ESP32-S3 in particular has become a go-to choice for more demanding projects thanks to its dual cores, Bluetooth 5.0, and native USB OTG support.

How it works. You write a YAML configuration file that declares your hardware — the board type, Wi-Fi credentials, sensors, switches, lights, or displays you have connected. ESPHome reads that file, generates C++ source code, compiles a firmware binary, and flashes it onto the device. Once running, the device communicates with Home Assistant over a secure, encrypted local API — no cloud, no MQTT broker required by default, though MQTT is supported if you prefer it.

Every sensor, switch, or light you declare in the YAML will appear automatically in Home Assistant's device registry. From there you can build automations, create dashboard cards, and set up alerts exactly as you would for any commercial device. If you want to see how automations work once your devices are live, our automations guide covers the full range of trigger and action options.

What You Need

To follow this guide you need:

  • A running Home Assistant instance (any installation method works). If you are new to Home Assistant, start with our Home Assistant UK setup guide.
  • An ESP32 or ESP8266 development board. The NodeMCU v2 (ESP8266) or an ESP32 DevKit v1 are the most widely stocked in the UK and cost around £3–£8 from Pimoroni, The Pi Hut, or various sellers on eBay and AliExpress.
  • A DHT22 temperature and humidity sensor (around £2–£5), a 4.7 kΩ resistor, and a few jumper wires for this tutorial.
  • A USB cable and a computer or Raspberry Pi to handle the initial USB flash.

Installing the ESPHome Add-on in Home Assistant

The fastest way to get started is through the official Home Assistant add-on. This is available on Home Assistant OS and Supervised installs. If you are running Home Assistant Container or Core, you can install ESPHome as a standalone Python package instead, but the add-on approach is recommended for beginners.

  1. In Home Assistant, go to Settings → Add-ons → Add-on Store.
  2. Search for ESPHome and select the official add-on published by ESPHome.
  3. Click Install and wait for the download and installation to complete (typically one to two minutes).
  4. Enable Start on boot and Show in sidebar, then click Start.
  5. Open the ESPHome dashboard from the sidebar.

ESPHome is one of the essential tools covered in our round-up of the best Home Assistant add-ons, alongside Mosquitto, Node-RED, and others worth installing at the same time.

Creating Your First Device: A DHT22 Temperature Sensor

A DHT22 sensor reads temperature and humidity and is a perfect first ESPHome project. The sensor costs under £5, needs only three connections to an ESP board, and the YAML configuration is short enough to understand in a few minutes.

Wiring the DHT22

Connect the DHT22 to your NodeMCU or ESP32 DevKit as follows:

  • VCC → 3.3 V pin on the board
  • GND → any GND pin
  • DATA → GPIO pin D2 (GPIO4 on NodeMCU) with a 4.7 kΩ pull-up resistor between DATA and 3.3 V

The pull-up resistor is required. Without it, the sensor will produce erratic readings or fail to respond entirely.

Writing the YAML Configuration

In the ESPHome dashboard click New Device, give it a name such as bedroom-sensor, and select your board type. ESPHome generates a minimal stub. Replace or extend it with the configuration below:

esphome:
  name: bedroom-sensor
  friendly_name: Bedroom Sensor

esp8266:
  board: nodemcuv2

logger:

api:
  encryption:
    key: "your-generated-encryption-key"

ota:
  - platform: esphome
    password: "your-ota-password"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  ap:
    ssid: "Bedroom-Sensor Fallback"
    password: "fallback-password"

captive_portal:

sensor:
  - platform: dht
    pin: D2
    model: DHT22
    temperature:
      name: "Bedroom Temperature"
    humidity:
      name: "Bedroom Humidity"
    update_interval: 60s

A few things to note. The !secret syntax pulls values from ESPHome's secrets file, keeping credentials out of your configuration — exactly like Home Assistant's own secrets.yaml. The update_interval of 60 seconds is a sensible default for a DHT22; going below 30 seconds can cause the sensor to overheat slightly and skew readings. The api block with an encryption key enables the native encrypted API that Home Assistant uses to communicate with the device.

Flashing the Firmware

Click Install in the ESPHome dashboard. For the first flash you must use a wired USB connection:

  1. Select Plug into this computer if you are running ESPHome on the same machine, or Plug into the computer running the ESPHome dashboard if it is on a Raspberry Pi or server.
  2. Connect the board via USB. ESPHome will detect the serial port automatically on most systems.
  3. Click Flash and wait. The process takes around two minutes for an ESP8266.

After the first flash, all future updates can be sent over Wi-Fi using OTA (Over-the-Air) updates. Just click Install → Wirelessly from the dashboard — the device reboots into the new firmware without needing a USB cable again.

Adding the Device to Home Assistant

Once the board is running and connected to your Wi-Fi, Home Assistant detects it automatically via the ESPHome integration. You will see a notification in Settings → Integrations prompting you to add the new device. Click Submit, enter the encryption key you set in the YAML, and the device is added.

Two new entities appear immediately: sensor.bedroom_temperature and sensor.bedroom_humidity. You can add these to a Lovelace dashboard using a standard Entities or Gauge card, or use them as conditions and triggers in automations — for example, turning on a fan when the bedroom temperature exceeds 24 °C.

Addressable LED strips. Connect a WS2812B or SK6812 LED strip to an ESP32 and ESPHome exposes it as a light entity in Home Assistant with full RGB colour control, brightness, and animated effects. This is a popular choice for under-cabinet kitchen lighting, bias lighting behind a TV, or stair lighting that reacts to motion.

DIY motion and door sensors. A PIR sensor or a reed switch costs under £2 and pairs with any ESP board. These make excellent room-presence or door-open sensors for rooms where commercial Zigbee sensors would be awkward to mount. If you already use Zigbee devices, our Zigbee2MQTT guide explains how to mix Zigbee and ESPHome devices in the same Home Assistant setup.

Shelly device integration. Shelly smart switches and relays ship with Tasmota or Shelly firmware, but many can be flashed with ESPHome. This gives you a locally controlled, encrypted smart switch that integrates more tightly with Home Assistant than the default Shelly cloud integration.

CO₂ and air quality monitors. Sensors such as the SCD40 or MH-Z19B plug into an ESP32 and give you accurate indoor CO₂ readings — useful for monitoring ventilation in a home office or bedroom. ESPHome has native components for both sensors.

Electricity monitoring. The PZEM-004T energy monitor pairs with ESPHome to give per-circuit energy readings, feeding data into Home Assistant's Energy dashboard alongside your smart meter data.

ESPHome vs Tasmota: Which Should You Use?

Both ESPHome and Tasmota are open-source firmware options for ESP-based devices, and both integrate with Home Assistant. The right choice depends on your use case.

Use ESPHome when:

  • You are building a custom DIY device from scratch and want to describe exactly what the hardware does.
  • You want the tightest possible integration with Home Assistant — entities appear automatically, no MQTT broker required.
  • Your project uses sensors, displays, or actuators that need custom logic in the firmware.
  • You value OTA updates and a single dashboard for managing all your ESP devices.

Use Tasmota when:

  • You are flashing an existing commercial device (such as a Sonoff Basic or a Gosund plug) and want a quick, web-UI-based setup without writing YAML.
  • You already have an MQTT broker and prefer a pub/sub messaging architecture.
  • The device has very limited flash memory — Tasmota's binary is slightly smaller and can fit on older ESP-01 modules with only 1 MB of flash.

In practice, many Home Assistant users run both: ESPHome for custom-built sensors and Tasmota for pre-built commercial devices they have reflashed for local control. The two systems coexist happily in the same Home Assistant instance.

Where to Buy ESP Boards in the UK

For reliable UK delivery, the following suppliers stock a wide range of ESP development boards:

  • Pimoroni (pimoroni.com) — excellent selection of ESP32-based boards including the Pimoroni Pico W and various Adafruit products.
  • The Pi Hut (thepihut.com) — NodeMCU, ESP32 DevKit, and Wemos D1 Mini boards, typically in stock and dispatched from the UK.
  • eBay UK — third-party sellers offer ESP8266 and ESP32 boards for £2–£5, though delivery from China can take two to three weeks.
  • AliExpress — the cheapest source for bulk orders if you are planning multiple sensor projects and can wait for shipping.

For a reliable first purchase, the Wemos D1 Mini (ESP8266) at around £3–£5 from Pimoroni or The Pi Hut is hard to beat. Its compact size makes it ideal for fitting inside sensor enclosures.

Getting More From ESPHome

Once you have your first device running, the ESPHome documentation at esphome.io is the best place to explore. The components reference covers hundreds of sensors, displays, and actuators with copy-paste YAML examples. The community on the Home Assistant forums is also active and helpful for troubleshooting unusual hardware combinations.

For those who want to extend Home Assistant further beyond ESPHome, our guide to custom components covers HACS and third-party integrations that complement a DIY sensor network nicely.

Frequently asked questions

What is ESPHome used for in Home Assistant?
ESPHome is used to create custom firmware for ESP8266 and ESP32 microcontrollers that integrate natively with Home Assistant. You describe your hardware in a YAML file — sensors, switches, LEDs — and ESPHome compiles and flashes the firmware. The device then appears automatically in Home Assistant without needing an MQTT broker or cloud connection.
Do I need to know how to code to use ESPHome?
No. ESPHome uses YAML configuration files rather than traditional programming code. You declare what hardware is connected and how it should behave, and ESPHome handles the underlying C++ compilation. Most beginner projects like temperature sensors or smart switches can be set up by copying and adapting examples from the ESPHome documentation.
What is the difference between ESPHome and Tasmota?
ESPHome is best for DIY custom-built devices where you define the hardware in YAML and want tight Home Assistant integration. Tasmota is better suited to flashing existing commercial ESP-based devices quickly via a web interface, and works well with MQTT-based setups. Many Home Assistant users run both simultaneously.
Can I use ESPHome without Home Assistant?
Yes. ESPHome can expose devices via MQTT, making them compatible with any MQTT-based home automation platform such as openHAB or Node-RED. However, the native encrypted API is designed specifically for Home Assistant and offers the smoothest experience when used with it.

Sources

Sources verified 2026-06-19

  1. ESPHome — Getting Started with ESPHome and Home Assistant
  2. ESPHome — DHT Temperature+Humidity Sensor Component
  3. ESPHome — ESP32 Platform — ESPHome
  4. Neil Turner's Blog — Comparing ESPHome and Tasmota
  5. Unsplash — Close up of dark blue circuit board — Vishnu Mohanan
Sepehr

Written by

Sepehr

Head of Engineering with 15+ years of software experience and a decade of hands-on smart home tinkering. I run everything I write about — Home Assistant, Zigbee2MQTT, Frigate, and a full self-hosted homelab. Independent coverage, no brand deals, UK-focused.

LinkedIn →

Related reading