ESPHome and Home Assistant Beginner Guide: Build Your First WiFi Sensor
ESPHome turns an ESP32 into a smart home sensor or controller with almost no code. Combined with Home Assistant, it is the most powerful DIY home automation setup available.
What You Will Build
A WiFi temperature and humidity sensor that reports every 30 seconds to Home Assistant, appears automatically in your dashboard, and survives reboots. Total hardware cost: under $10.
Hardware Needed
- ESP32 DevKit (~$5)
- BME280 temperature/humidity/pressure sensor (~$4) — recommended over DHT22 for accuracy
- USB cable, jumper wires
Wire the BME280 (I2C)
BME280 PinESP32 Pin VCC3.3V GNDGND SDAGPIO 21 SCLGPIO 22Install ESPHome
In Home Assistant: Settings → Add-ons → Add-on Store → search ESPHome → Install → Start.
Create Your Device
ESPHome dashboard → New Device → name it → Edit. Paste this configuration:
esphome: name: workshop-sensor friendly_name: Workshop Sensor esp32: board: esp32dev logger: api: encryption: key: !secret api_key ota: password: !secret ota_password wifi: ssid: !secret wifi_ssid password: !secret wifi_password ap: ssid: "Fallback Hotspot" password: "fallback123" i2c: sda: GPIO21 scl: GPIO22 sensor: - platform: bme280_i2c temperature: name: "Temperature" pressure: name: "Pressure" humidity: name: "Humidity" address: 0x76 update_interval: 30sFlash Your ESP32
ESPHome dashboard → Install → Plug into this computer → select USB port → Install.
First flash takes 2–3 minutes to compile. Future updates are wireless (OTA).
Connect to Home Assistant
HA will auto-discover the device. Settings → Devices & Services → Configure. Your sensors are now available for automations and dashboards.
What to Build Next
ESPHome supports nearly any hardware with simple YAML additions:
- Motion sensor (PIR) — trigger automations on presence
- Door/window sensor (reed switch) — detect open/close
- RGB LED controller — control strips from HA
- Smart relay switch — control lights or appliances
- CO2 monitor (MH-Z19B) — air quality
- Water leak detector — under-sink protection
- Energy monitor (PZEM-004T) — whole-home power monitoring
Each takes 10–30 lines of YAML and works exactly like the temperature sensor.
ESPHome vs Tasmota
Both flash open-source firmware to ESP devices. ESPHome is YAML-configured and tightly integrated with Home Assistant. Tasmota works with more platforms but is more complex. If you use HA, ESPHome wins.
Related Guides
- Running Home Assistant on a Raspberry Pi 4
- Arduino vs ESP32: Which Should You Use? A Practical Comparison
- Getting Started with ESP32: GPIO, WiFi, and Your First Project
- Setting Up Marauder on the ESP32 Wi-Fi Dev Board for Flipper
- Home Assistant on Raspberry Pi: Complete Server Setup
- Tying It Together: Pi + ESP32 + Flipper Home Automation Hub