Getting Started with ESPHome on Home Assistant: A Complete Beginner’s Guide

ESPHome is a powerful system that allows you to control ESP8266 and ESP32 microcontrollers directly from Home Assistant without writing complex code. Instead of dealing with Arduino IDE or complex programming, ESPHome uses simple YAML configuration files to create custom firmware for your devices. This guide will walk you through setting up ESPHome and creating your first sensor.

What You’ll Need

Before starting, gather these components:

  • A computer with Home Assistant installed (Home Assistant OS, Supervised, or Container)
  • An ESP8266 or ESP32 development board (NodeMCU, Wemos D1 Mini, or similar)
  • A USB cable to connect your ESP board to your computer
  • A basic sensor (we’ll use a DHT22 temperature/humidity sensor for this example)
  • Jumper wires and a breadboard
  • WiFi network credentials

Step 1: Installing the ESPHome Add-on

First, you need to install ESPHome as a Home Assistant add-on:

  1. Open your Home Assistant web interface
  2. Navigate to SettingsAdd-ons
  3. Click the Add-on Store button
  4. Search for “ESPHome” in the official add-ons
  5. Click on ESPHome and then Install
  6. After installation completes, toggle Start on boot and Watchdog
  7. Click Start to launch the add-on
  8. Once started, click Open Web UI

The ESPHome dashboard should now open in a new tab. This is where you’ll manage all your ESP devices.

Step 2: Creating Your First Device

Now let’s create your first ESPHome device:

  1. In the ESPHome dashboard, click the green + NEW DEVICE button
  2. Click Continue on the welcome screen
  3. Give your device a name (e.g., “bedroom-sensor”)
  4. Select your device type:
    • Choose ESP8266 if using NodeMCU, Wemos D1 Mini, etc.
    • Choose ESP32 if using an ESP32 board
  5. Enter your WiFi credentials when prompted
  6. Click Next and then Skip (we’ll add the sensor manually)

ESPHome will generate a basic configuration file for your device.

Step 3: Wiring Your Sensor

For this example, we’ll connect a DHT22 temperature and humidity sensor:

DHT22 to ESP8266/ESP32 connections:

  • VCC (power) → 3.3V or 5V pin
  • GND (ground) → GND pin
  • DATA → GPIO pin (we’ll use D2 on ESP8266 or GPIO4 on ESP32)

Make sure all connections are secure before proceeding.

Step 4: Configuring Your Sensor

Back in the ESPHome dashboard:

  1. Click Edit on your newly created device
  2. You’ll see a YAML configuration file. Add the sensor configuration after the existing code:
yaml<code>sensor:
  - platform: dht
    pin: D2  <em># Use GPIO4 for ESP32</em>
    temperature:
      name: "Bedroom Temperature"
      id: bedroom_temp
    humidity:
      name: "Bedroom Humidity" 
      id: bedroom_humidity
    update_interval: 60s</code>

The complete configuration should look something like this:

yaml<code>esphome:
  name: bedroom-sensor
  friendly_name: bedroom-sensor

esp8266:  <em># or esp32</em>
  board: nodemcuv2  <em># adjust based on your board</em>

<em># Enable logging</em>
logger:

<em># Enable Home Assistant API</em>
api:
  encryption:
    key: "your-generated-key-here"

ota:
  password: "your-ota-password"

wifi:
  ssid: "Your-WiFi-Name"
  password: "your-wifi-password"
  
  <em># Enable fallback hotspot</em>
  ap:
    ssid: "Bedroom-Sensor Fallback Hotspot"
    password: "fallback-password"

captive_portal:

sensor:
  - platform: dht
    pin: D2
    temperature:
      name: "Bedroom Temperature"
      id: bedroom_temp
    humidity:
      name: "Bedroom Humidity"
      id: bedroom_humidity
    update_interval: 60s</code>

Step 5: Installing the Firmware

Now it’s time to flash this configuration to your ESP device:

  1. Click Save to save your configuration
  2. Connect your ESP board to your computer via USB
  3. Click Install in the ESPHome dashboard
  4. Choose Plug into the computer running ESPHome Dashboard
  5. Select the correct COM port for your device
  6. Click Install

ESPHome will compile the firmware and flash it to your device. This process takes a few minutes the first time.

Step 6: Adding the Device to Home Assistant

Once flashing is complete:

  1. Your ESP device should restart and connect to WiFi
  2. In Home Assistant, go to SettingsDevices & Services
  3. You should see a notification about a new ESPHome device discovered
  4. Click Configure and then Submit
  5. Your device will be added to Home Assistant

If the device doesn’t appear automatically:

  1. Click Add Integration
  2. Search for and select ESPHome
  3. Enter the IP address of your ESP device
  4. Leave the port as 6053 and click Submit

Step 7: Viewing Your Sensor Data

Your sensor data should now be available in Home Assistant:

  1. Go to SettingsDevices & ServicesESPHome
  2. Click on your device to see all its entities
  3. Navigate to Developer ToolsStates to see real-time values
  4. Add the sensors to your dashboard by going to Overview and clicking Edit Dashboard

Understanding the Configuration

Let’s break down what each part of the configuration does:

Basic Device Setup:

  • esphome: section defines the device name and friendly name
  • esp8266: or esp32: specifies the microcontroller type and board
  • wifi: contains your network credentials and fallback hotspot settings

Communication:

  • api: enables communication with Home Assistant
  • ota: allows over-the-air updates after initial setup
  • logger: enables serial logging for debugging

Sensor Configuration:

  • platform: dht specifies we’re using a DHT sensor
  • pin: defines which GPIO pin the sensor is connected to
  • temperature: and humidity: create separate entities for each measurement
  • update_interval: sets how often the sensor reads new values

Troubleshooting Common Issues

Device won’t flash:

  • Ensure the correct COM port is selected
  • Try a different USB cable
  • Press and hold the BOOT button on some ESP32 boards during flashing

Device not connecting to WiFi:

  • Double-check WiFi credentials in the configuration
  • Ensure your WiFi network uses 2.4GHz (ESP devices don’t support 5GHz)
  • Check if your network has special characters that need escaping

Sensor readings are incorrect:

  • Verify wiring connections
  • Ensure adequate power supply (some sensors need 5V instead of 3.3V)
  • Check if the sensor requires a pull-up resistor

Device not appearing in Home Assistant:

  • Wait a few minutes after flashing
  • Check the ESPHome logs for connection errors
  • Manually add the device using its IP address

Next Steps

Now that you have your first ESPHome sensor working, you can expand your setup:

Add more sensors: Motion detectors, light sensors, door/window sensors Add outputs: Control LEDs, relays, or servo motors Create automations: Use your sensor data to trigger actions in Home Assistant Update wirelessly: After the initial flash, you can update your device configuration over WiFi

Tips for Success

  • Start simple with one sensor before adding complexity
  • Keep your YAML indentation consistent (use spaces, not tabs)
  • Use the ESPHome logs to debug issues
  • Name your devices and sensors clearly for easy identification
  • Test your wiring with a multimeter if sensors aren’t working
  • Keep your ESPHome configurations backed up

ESPHome opens up endless possibilities for custom sensors and automation devices. With this foundation, you can create a comprehensive smart home system tailored exactly to your needs. The beauty of ESPHome lies in its simplicity – complex functionality through simple configuration files, all integrated seamlessly with Home Assistant.

Leave a Comment

Your email address will not be published. Required fields are marked *

Shopping Cart
Scroll to Top