ESPHome sensors in Home Assistant
Build it step by step
0 of 8 doneInstall ESPHome
Use the add-on in Home Assistant or pip install esphome.
Create the device
Make a new device named living-room and paste the YAML above.
Set your Wi-Fi secrets
Add wifi_ssid and wifi_password to secrets.yaml.
Flash by USB
Connect the ESP32 and press Install, choosing the serial port.
Adopt it
Home Assistant discovers the device. Click Configure to add it.
Check readings
Temperature, humidity, pressure and motion appear.
Make an automation
Turn on a light on motion between sunset and sunrise.
Update over the air
Change update_interval and install wirelessly.
How do you build an ESPHome sensors in Home Assistant?
Write a YAML file, flash an ESP32 and a new sensor appears in Home Assistant with no code. You need ESP32 DevKit V1, BME280 Environmental Sensor, PIR Motion Sensor HC-SR501, 5 V 2 A USB adapter, USB A to micro-USB cable (data) and Jumper wires male to male (40 pcs, 20 cm). It takes 8 steps and about 60 minutes.
- Level
- Beginner
- Time
- About 60 min
- Parts
- 6
Parts list
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| BME280 VIN and GND | ESP32 3V3 and GND | Sensor supply |
| BME280 SDA | ESP32 GPIO 21 | I2C data |
| BME280 SCL | ESP32 GPIO 22 | I2C clock |
| PIR VCC and GND | ESP32 VIN (5 V) and GND | The HC-SR501 needs 5 V |
| PIR OUT | ESP32 GPIO 27 | Motion signal at 3.3 V |
| Power | USB adapter into the ESP32 | Flash by USB the first time |
Code
ESPHome, either the Home Assistant add-on or the command line tool, version 2024.6 or newer for the ota: platform syntax shown. Put wifi_ssid and wifi_password in the secrets file, and never paste them into a shared file. The BME280 address is 0x76 on most modules and 0x77 on some.
# Save as living-room.yaml in the ESPHome dashboard
esphome:
name: living-room
esp32:
board: esp32dev
framework:
type: arduino
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
api:
ota:
- platform: esphome
logger:
i2c:
sda: 21
scl: 22
sensor:
- platform: bme280_i2c
address: 0x76
temperature:
name: "Living room temperature"
humidity:
name: "Living room humidity"
pressure:
name: "Living room pressure"
update_interval: 60s
binary_sensor:
- platform: gpio
pin: GPIO27
name: "Living room motion"
device_class: motionTest checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Device online | Shows connected in the ESPHome dashboard |
| Temperature | Within 1 to 2 °C of a thermometer |
| Wave a hand at the PIR | Motion shows detected, then clear after the PIR's delay |
| OTA update | Works without the USB cable |
If it does not work
BME280 not found
Try address 0x77 and check SDA and SCL wires.
Device does not appear in Home Assistant
It is on a different network or the API is blocked. Check Wi-Fi and the logs.
PIR always on
Its sensitivity and time pots are set high. Turn them down and give it a minute to settle.
Compile error
ESPHome version differs. Update it and check the ota syntax.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the ESPHome sensors in Home Assistant?
ESP32 DevKit V1, BME280 Environmental Sensor, PIR Motion Sensor HC-SR501, 5 V 2 A USB adapter, USB A to micro-USB cable (data) and Jumper wires male to male (40 pcs, 20 cm).
How long does the ESPHome sensors in Home Assistant take to build?
About 60 minutes for a beginner maker, in 8 steps.
How do I know the ESPHome sensors in Home Assistant works?
Device online: Shows connected in the ESPHome dashboard. Temperature: Within 1 to 2 °C of a thermometer. Wave a hand at the PIR: Motion shows detected, then clear after the PIR's delay.
BME280 not found: what should I check?
Try address 0x77 and check SDA and SCL wires.
Device does not appear in Home Assistant: what should I check?
It is on a different network or the API is blocked. Check Wi-Fi and the logs.
PIR always on: what should I check?
Its sensitivity and time pots are set high. Turn them down and give it a minute to settle.
Compile error: what should I check?
ESPHome version differs. Update it and check the ota syntax.
