Table of Contents

  1. What Is ESPHome?
  2. Hardware You Need
  3. Installing ESPHome
  4. Your First Device
  5. Adding Sensors
  6. Home Assistant Integration
  7. 5 Beginner Projects

ESPHome is a system that lets you program ESP8266 and ESP32 microcontrollers using simple YAML configuration files. No C++ required. No complex IDEs. Just write a config file describing what your device should do, and ESPHome compiles and flashes the firmware automatically.

The result integrates natively with Home Assistant via an encrypted local API. Your custom sensor appears in HA just like any commercial device — but you built it yourself, it works exactly how you want, and it costs a fraction of off-the-shelf alternatives.

What Is ESPHome?

ESPHome bridges the gap between DIY electronics and professional smart home automation. Here's what makes it special:

Hardware You Need

Microcontrollers

Common Sensors

Other Essentials

Installing ESPHome

The easiest way to use ESPHome if you already have Home Assistant OS or Supervised is via the ESPHome add-on.

ESPHome Add-on

  1. In Home Assistant, go to Settings → Add-ons → Add-on Store
  2. Search for "ESPHome" and install it
  3. Start the add-on and open the web interface

ESPHome Dashboard

The ESPHome dashboard is where you create and manage your device configs. It shows all your ESPHome devices and their online status, and lets you compile/flash firmware directly from the browser.

Your First Device

Let's create a simple temperature and humidity sensor using a D1 Mini and DHT22.

Step 1: Create New Device

In the ESPHome dashboard, click "New Device". Enter a name (e.g., "bedroom-sensor") and select your board type (D1 Mini). ESPHome generates a basic config with WiFi credentials.

Step 2: Add the DHT22 Sensor

Edit the generated config and add:

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

Step 3: First Flash (Wired)

The first flash must be done via USB. Connect your D1 Mini to your computer or HA server via USB. In the ESPHome dashboard, click "Install" → "Plug into this computer". ESPHome will compile the firmware and flash it.

Step 4: OTA Updates Forever After

After the initial wired flash, all future updates happen wirelessly (OTA). Just edit the YAML and click "Install" — no cables needed.

Adding Sensors

Here's a quick reference for adding common sensors:

BME280 (Temperature, Humidity, Pressure) via I2C

i2c:
  sda: D2
  scl: D1

sensor:
  - platform: bme280_i2c
    temperature:
      name: "Temperature"
    pressure:
      name: "Pressure"
    humidity:
      name: "Humidity"

PIR Motion Sensor

binary_sensor:
  - platform: gpio
    pin: D3
    name: "Motion"
    device_class: motion

Home Assistant Integration

Once your ESPHome device is online, Home Assistant detects it automatically on the local network. You'll see a notification: "ESPHome device discovered". Click to add it — no configuration needed on the HA side.

Your sensor entities appear immediately: sensor.bedroom_temperature, sensor.bedroom_humidity, etc. You can use these in any HA automation, dashboard, or notification.

5 Beginner Projects

1. Whole-Home Temperature Map

Place D1 Mini + DHT22 sensors in every room. Track temperature differences, identify cold spots, and automate heating/cooling based on actual room temperatures.

2. Mailbox Notifier

Use an ESP32 with a reed switch on your mailbox. When the lid opens, HA sends a push notification: "You've got mail!" Use deep sleep mode to run for months on a small battery.

3. Plant Soil Monitor

Add a capacitive soil moisture sensor to an ESP32. Get HA notifications when your plants need water, or automate a small pump relay.

4. Garage Door Monitor

Mount a D1 Mini with a magnetic reed switch on your garage door. Know instantly if you left it open, and trigger an HA automation to notify you after 10 minutes.

5. CO2 Air Quality Monitor

Pair an ESP32 with an SCD40 CO2 sensor. Monitor air quality in your home office, and automate a fan or send alerts when CO2 levels rise above 1000 ppm.

Bottom Line

ESPHome is the best tool available for custom Home Assistant sensors. The YAML-based approach makes it accessible to non-programmers, the HA integration is seamless, and the hardware costs are tiny. Even a single DIY sensor project will save you money compared to commercial alternatives — and you'll learn something along the way.

SmartWired participates in the Amazon Associates Programme. We may earn a commission from qualifying purchases at no extra cost to you.