- ESPHome turns an ESP32 into a Home Assistant device using YAML files, without C++ or MQTT.
- OTA updates allow new firmware to be sent via WiFi after the first flash.
- Sensors such as DHT22, DHT11 or BME280 integrate with very little configuration.
- Home Assistant automatically discovers the device, and there are also projects ready to flash from the browser.
ESPHome is an open-source firmware framework that transforms boards like the ESP32, ESP8266, or even the RP2040 into smart home devices without requiring you to wrestle with C++ or the Arduino IDE. The idea is simple: you describe your hardware and how it's connected in YAML files, and ESPHome takes care of generating custom firmware, compiling it, and installing it on the board. As soon as the device connects to Wi-Fi, it appears in Home Assistant with its entities ready to use.
The beauty of this system is its native integration with Home Assistant , without MQTT or any complicated intermediaries. Furthermore, once flashed via USB, updates can be delivered over-the-air (OTA) via Wi-Fi. This guide will cover everything from installing the plugin to setting up your first temperature and humidity sensor, including flashing, connecting to Home Assistant, YAML examples, and those details that often trip up beginners.
What is ESPHome and why is it such a good fit with an ESP32?
ESPHome has two parts: the firmware that runs on the microcontroller and the management tool that runs on a computer, a Raspberry Pi, or Home Assistant itself. This tool can be the ESPHome Device Builder plugin within Home Assistant, a Docker installation, or even a pip installation on a machine running Python. From one or more YAML files, it compiles custom firmware and uploads it to the board.
The ESP32 is an inexpensive, low-power chip from Espressif with integrated Wi-Fi and Bluetooth ; the ESP8266 is its smaller sibling and is also supported. Unlike Arduino or Tasmota, ESPHome uses a declarative configuration approach: you specify what you want, not how to program it. This translates into over-the-air (OTA) updates, automatic detection in Home Assistant, and a fairly active community.
- Declarative configuration using YAML, without writing C++.
- Native integration with Home Assistant, without MQTT or middleware.
- Over-the-air (OTA) updates after the first flash.
- Automatic detection of entities and devices.
- Compatible with ESP32, ESP8266 and other supported boards.
Before you begin: materials, drivers, and installation options
For a first project, you don't need much: an ESP32 DevKit or ESP32 NodeMCU board, a DHT22 or DHT11 sensor , Dupont cables, and a microUSB cable. The ESP32-WROOM-32 is a very common choice due to its compatibility, and the DHT22 is also sold as the AM2302. If you want to measure pressure in addition to temperature and humidity, the BME280 costs a bit more and connects via I2C.
- ESP32 DevKit or NodeMCU board, preferably with ESP32-WROOM-32 chip.
- DHT22, DHT11 or BME280 sensor for temperature and humidity.
- Dupont cables to connect the sensor without soldering.
- MicroUSB cable for the first connection to the computer or Home Assistant device.
- Power adapter, power bank or battery to power the board afterwards.
Regarding software, the easiest way is to install ESPHome as an add-on to Home Assistant if you're using Home Assistant OS or Supervised. If you have Home Assistant Core, you can use Docker or install ESPHome with pip on a computer. For flashing from a PC, there's also ESPHome Flasher, a portable tool. On Windows, you'll need the USB chip drivers: CH341 for rectangular boards and CP2102 for square ones. Afterward, a COM port should appear in Device Manager.

Install ESPHome in Home Assistant step by step
Within Home Assistant, go to Settings → Add-ons Store and search for ESPHome. Install it, wait for it to finish, tap Start, and then Open the web interface. You can also access it through the sidebar by enabling Show in sidebar, or via the usual address using port 6052. In the add-on options, it's advisable to select Start on boot so that it only launches when you restart the server.
If you encounter a strange error when opening the YAML editor, restart the plugin using its Restart button ; in many cases, this resolves the issue. You can also access it via Supervisor → Add-ons, where ESPHome is usually listed in the community repository. If you want to try beta or development versions, add the repository using the three dots and refresh the list, although there's no need to overcomplicate things to get started. If you don't use plugins, the alternative is to run ESPHome Device Builder in Docker or install ESPHome on a computer.
- Install the add-on from the store and open it.
- Activate automatic startup and shortcut in the sidebar.
- If the editor fails, restart the service.
- The configuration files are saved in /esphome/; to access them via SSH you would have to disable protection mode and assess the risk.
Create the first configuration and choose the board
When you open the web interface for the first time, a wizard will guide you through creating the first node . Enter a lowercase name, preferably with hyphens, for example, living-room-sensor. Choose the board type, such as ESP32 DevKit v1, and enter the SSID and Wi-Fi password. You'll also define an API key that you'll use when adding the device to Home Assistant. No expertise is required: the wizard generates a basic YAML file with the essentials.
In that YAML file, you'll see components like esphome, wifi, captive_portal, logger, api, and ota . The esphome block identifies the board and its name; wifi stores the credentials and the emergency access point; captive_portal helps configure the network; logger displays events; api enables native connection with Home Assistant; and ota enables remote updates. You can add web_server, although don't expect a fully editable web panel: it only exposes information and logs on port 80, requiring authentication.
The initial installation on a new board is usually the most daunting step, but it's always done via USB . Subsequent updates can be done wirelessly. Before flashing, double-check that the sensor pin matches the one you specified in the YAML file and that the board is properly connected.

Connect a DHT22, a DHT11 or a BME280
Wiring a DHT22 is very simple: VCC to 3,3V, GND to GND, and DATA to a GPIO pin . In one example, GPIO22 is used, and in another, GPIO4; the important thing is that the pin in the code matches the wire. The DHT22 can operate at 3V or 5V, and if the readings are unstable, a 10kΩ pull-up resistor between VCC and DATA is recommended, although many modules already have one. The DHT11 is usually connected to GPIO2 and also has an internal resistor in many cases.
For a BME280, the main change is that it uses I2C instead of a digital pin . The bus is configured with SDA on GPIO21 and SCL on GPIO22, and then the temperature, humidity, and pressure entities are added. This sensor allows for more refined automation, because the atmospheric pressure provides weather context. If you see D2-type pins and they don't work, try GPIO2; the naming convention varies depending on the board version.
An example configuration for DHT22 would be this, with GPIO4 as the data pin :
sensor:
- platform: dht
pin: GPIO4
model: DHT22
temperature:
name: Salon Temperatura
humidity:
name: Salon Humedad
update_interval: 30s
With BME280 , the YAML would look like this:
i2c:
sda: GPIO21
scl: GPIO22
sensor:
- platform: bme280_i2c
temperature:
name: Salon Temperatura
humidity:
name: Salon Humedad
pressure:
name: Salon Presion
update_interval: 30s
The 30-second interval is a good balance between fresh data and sensor lifespan . There's no need to update every second for an environmental measurement. However, remember that saving the YAML file doesn't magically update the board: you have to recompile and reinstall.
Compile, flash via USB, and update via OTA
With the saved configuration, click Install or Compile in the ESPHome panel. The tool will download the necessary libraries and generate the binary; this may take a minute or more. If you are using the plugin and your board is connected to the computer running Home Assistant, you can choose the USB option. If you prefer to do it from your computer, download the .bin file and use ESPHome Flasher: select the COM port, locate the binary, and click Flash ESP.
The first time, you always need to connect the board via cable , as it's not yet on the Wi-Fi network. Connecting the board directly to the Home Assistant device might work, although it sometimes causes detection problems; if this happens, use ESPHome Flasher on your computer. Some boards automatically enter flashing mode; if they don't, hold down the Boot button at the start. If the process fails with a sensor connected, try disconnecting it, flashing the board, and then reconnecting it. Once finished, ESPHome Flasher can display real-time logs, so you'll see it connect to Wi-Fi and start reporting data.
After the initial flash, you can power the board with a power adapter, power bank, or battery, and update it via Wi-Fi. Each time you change the YAML file, press Install to recompile and upload the firmware. Each node's menu also includes actions such as Validate, Install, Clean build files, and Delete , in addition to Edit and Logs. The Update option appears if the device's ESPHome version is outdated.
Add the ESP32 to Home Assistant
When the sensor connects to the network, Home Assistant usually detects it automatically via mDNS and displays a new device notification. Tap Configure, enter the API key you defined, and you'll see the temperature, humidity, or other sensors you configured. If it doesn't appear automatically, go to Settings → Devices & Services → Add Integration, search for ESPHome, and enter the hostname, for example, salon-sensor.local, or its IP address.
Repeat the process for each device you add. You don't need MQTT or any intermediate plugins : the native integration handles everything. The entities become available for dashboards, automations, and scripts. If you want a more visually appealing card, you can use a custom card from HACS; and if you enjoy analyzing data, you can also export it to InfluxDB and create charts in Grafana.

Add a binary switch or sensor using YAML
In addition to environmental sensors, ESPHome allows you to control a relay or read a contact with very few lines. For example, a switch connected to GPIO5 could be used to turn on a light, a fan, or a dehumidifier. The name is just a guide; what's important is that the pin matches the connected hardware.
switch:
- platform: gpio
name: Deshumidificador salon
pin: GPIO5
For a binary sensor, such as a window detector, a pin configured as an input with pull-up resistor and inverted logic can be used depending on how it is mounted:
binary_sensor:
- platform: gpio
name: Ventana salon
pin:
number: GPIO0
inverted: true
mode:
input: true
pullup: true
After editing, save and reinstall. Any hardware defined in the YAML will appear in Home Assistant as an entity. That's one of the great advantages: you don't have to create custom web servers or write communication protocols.

Ready projects without writing YAML
If you're not yet keen on working with YAML, ESPHome includes Ready-Made Projects , a collection of pre-configured boards that can be installed directly from your browser. Go to esphome.io/projects, choose the project, connect your board via USB, and click Install. In Chrome or Edge using WebSerial, you can flash it directly without installing anything on your computer in just a couple of minutes.
Common options include a voice assistant with the ESP32-S3-BOX , a Bluetooth proxy to extend the range of Home Assistant, a media player for multiroom audio with Sendspin, an infrared proxy to control TVs and air conditioners, or a blank device to customize with YAML. For a first experience, the blank device or a simple sensor is the best entry point.
Ideas for the second project and practical tips
Once you've seen your initial data in Home Assistant, the next step could be a door or window sensor with a reed switch , a relay to control lights, a 0,96-inch OLED display, an air quality sensor like the MQ-135 or SGP30, or a WS2812B RGB LED strip. Everything is configured with YAML, updated over the air (OTA), and appears in Home Assistant with relative ease.
- Start with a sensor and a board; there will be time to get complicated later.
- Use descriptive names, such as kitchen_temperature, instead of sensor_1.
- Make copies of your YAML files; losing your configuration hurts.
- If the WiFi is not working properly, assign a static IP address from the router.
- The ESPHome forum and the Reddit community are good places to ask questions.
It's also worth remembering that the ESP32 isn't a powerful web server : the web_server component is only good for viewing logs and little else. Don't expect to modify a web panel like a full-fledged application. And if the ESPHome editor gets stuck, restart the plugin before assuming the board is broken.
Having an ESP32 with ESPHome is one of the most affordable ways to get into DIY home automation: you don't need to know C++, updates are done via Wi-Fi, and Home Assistant recognizes the device without any complex setup. With a board, a sensor, and a short YAML file, you can go from a drawer full of gadgets to a useful sensor in your home. The key is to start simple, check the pinout, flash it via USB the first time, and let the rest of the ecosystem do the heavy lifting.
FAQ
What advantages does ESPHome have over Arduino or Tasmota on an ESP32?
ESPHome allows you to describe the hardware in YAML, update via WiFi, and integrate natively with Home Assistant without MQTT or C++ programming.
Can I use ESPHome if my Home Assistant doesn't have any add-ons?
You can run ESPHome Device Builder in Docker or install ESPHome with pip on a computer, although the Home Assistant plugin is the most convenient option.
Which sensor should I get started with ESPHome and ESP32?
A DHT22 or a DHT11 are economical options for temperature and humidity; the BME280 adds pressure and connects via I2C.
Why doesn't the ESP32 appear in Home Assistant after flashing it?
The network may not support mDNS, or the device may not yet be connected to WiFi; add ESPHome integration with the IP address or .local name.
How do I update an ESP32 with ESPHome without reconnecting it via USB?
Once flashed for the first time, the device supports OTA updates over WiFi every time you change the YAML and reinstall the firmware.
What do I do if the COM port doesn't appear when I connect the ESP32?
Check the USB cable, install the CH341 or CP2102 driver depending on the board and try holding down the Boot button when connecting; if it still fails, disconnect sensors during flashing.
Is it possible to flash ESPHome without writing YAML?
There are projects ready to flash from the browser at esphome.io/projects, although for custom settings you will sooner or later end up touching YAML.
What is the solution if the ESPHome editor does not open the YAML?
This is often resolved by restarting the plugin using the Restart button; if the problem persists, check the logs and service status.
Table of Contents
- 1 What is ESPHome and why is it such a good fit with an ESP32?
- 2 Before you begin: materials, drivers, and installation options
- 3 Install ESPHome in Home Assistant step by step
- 4 Create the first configuration and choose the board
- 5 Connect a DHT22, a DHT11 or a BME280
- 6 Compile, flash via USB, and update via OTA
- 7 Add the ESP32 to Home Assistant
- 8 Add a binary switch or sensor using YAML
- 9 Ready projects without writing YAML
- 10 Ideas for the second project and practical tips
- 11 FAQ