ESPHome and ESP32: Building Custom Smart Home Sensors for Under $10
I remember the first time I put a $6 ESP32 board with a $3 temperature sensor on my workbench, flashed it with ESPHome, and watched it appear automatically in Home Assistant. Real-time temperature and humidity readings, updating every 30 seconds, fully integrated with my dashboards and automations. Total cost: about $9. A commercial Aqara temperature sensor does the same thing for $18-25, and that's considered cheap. A lot of commercial sensors are $30-50+.
ESPHome has become one of my favorite parts of the Home Assistant ecosystem. It lets you build exactly the sensors you need, at a fraction of the cost, using simple YAML configuration files instead of writing actual code. If you can edit a text file, you can build ESPHome devices.
What Is ESP32 and ESPHome?
The ESP32 is a microcontroller made by Espressif Systems. It's a tiny computer — about the size of a postage stamp — with built-in WiFi and Bluetooth. Development boards that include the ESP32 chip along with a USB port for programming and pin headers for connecting sensors cost about $5-8. You can buy them on Amazon (search "ESP32 dev board") or cheaper in bulk from AliExpress. The ESP32-WROOM-32 and ESP32-S3 are the most common variants you'll see.
ESPHome is a firmware framework that runs on ESP32 (and the older ESP8266) boards. Instead of writing C++ code like you would with Arduino, you write a YAML configuration file that describes what sensors are connected and how they should behave. ESPHome compiles this into firmware and flashes it to the board. Once running, the device automatically connects to your WiFi and integrates with Home Assistant through its native API — no MQTT setup needed (though MQTT is supported if you prefer).
The ESPHome project is now officially part of the Home Assistant ecosystem, maintained by Nabu Casa. It has an active community and supports hundreds of sensor types, displays, LEDs, relays, and other components out of the box.
Getting Started: Your First ESPHome Device
Here's what you need:
- An ESP32 development board ($5-8 on Amazon, $3-4 on AliExpress)
- A USB-C or Micro-USB cable (most dev boards come with one)
- Home Assistant with the ESPHome add-on installed
To install the ESPHome add-on: go to Settings → Add-ons → Add-on Store, search for "ESPHome", and click Install. Once running, open the ESPHome dashboard from the sidebar.
Click "New Device", give it a name (like "office-sensor"), and select your board type (ESP32 for most boards). ESPHome will generate a base configuration. The first flash needs to be done over USB — plug the ESP32 into the computer running Home Assistant (or use the ESPHome Web flasher at web.esphome.io from any computer with Chrome). After the first flash, all future updates are done wirelessly over WiFi (OTA updates).
Once flashed with the base config, the ESP32 will connect to your WiFi and show up in Home Assistant automatically under Settings → Devices & Services → ESPHome. You now have a networked microcontroller ready for sensors.
Project 1: Temperature and Humidity Sensor (~$9 total)
The classic starter project. You need an ESP32 dev board and either a DHT22 (~$3) or a BME280 (~$4) sensor module.
The DHT22 measures temperature and humidity. It's simple — three wires (power, ground, data) and a one-line config in ESPHome. The BME280 is a step up — it measures temperature, humidity, and barometric pressure, and it's more accurate than the DHT22. It connects via I2C (four wires: power, ground, SDA, SCL).
For the BME280, the ESPHome YAML looks like this:
sensor:
- platform: bme280_i2c
temperature:
name: "Office Temperature"
humidity:
name: "Office Humidity"
pressure:
name: "Office Pressure"
address: 0x76
update_interval: 30s
That's it. Flash it, and three sensors appear in Home Assistant. You can use them in automations, display them on dashboards, track history — everything a commercial sensor does. Wire the BME280 to the ESP32's 3.3V, GND, GPIO21 (SDA), and GPIO22 (SCL) pins, and you're done.
Project 2: Door/Window Sensor (~$7 total)
A reed switch costs about $1 for a pack of several. It's a magnetic switch — when a magnet is near it, the circuit closes. Tape the magnet to the door and the reed switch (wired to the ESP32) to the door frame. When the door opens, the magnet moves away, the circuit opens, and ESPHome reports the state change.
The config is dead simple:
binary_sensor:
- platform: gpio
pin:
number: GPIO4
mode: INPUT_PULLUP
name: "Front Door"
device_class: door
The main limitation compared to a commercial Zigbee door sensor is that the ESP32 needs to be plugged into USB power (or a battery, but battery life is poor on WiFi — more on that later). So this works best in locations where you can run a USB cable or hide a small USB power supply nearby.
Project 3: Garage Door Controller (~$10 total)
This is one of the most popular ESPHome projects. Most garage door openers have two terminals on the back — shorting them together triggers the door to open or close (same as pressing the wall button). A relay module connected to an ESP32 can short those terminals on command.
You need an ESP32 and a relay module (~$2 for a single-channel relay). Wire the relay to the garage door opener's terminals, add a reed switch or ultrasonic distance sensor to detect whether the door is open or closed, and you have a fully functional smart garage door controller for about $10.
ESPHome has a dedicated cover component for garage doors that handles the open/close logic, state detection, and safety checks. Compare that to a Chamberlain MyQ ($30+) or a Ratgdo board ($30+) and the savings are real — though those commercial options are plug-and-play while this requires some wiring.
Project 4: Room Presence Detection with mmWave (~$12 total)
This is the project I'm most excited about. The HLK-LD2410 is a 24GHz mmWave radar sensor that costs about $4-5. It detects human presence — not just motion, but actual presence. It can tell if someone is sitting still in a room, which regular PIR motion sensors cannot do. This is a game-changer for automations like "turn off the lights when the room is truly empty" instead of "turn off the lights when nobody has moved for 5 minutes."
Wire the LD2410 to an ESP32, add the ESPHome configuration, and you get a presence binary sensor plus distance and energy readings. The sensor can detect a stationary person at up to about 6-8 feet (depending on the model variant) and a moving person much further.
I have one of these in my office running on an ESP32-S3 board. The total build cost was about $12, and it completely replaced the PIR motion sensor I was using for light automation. No more lights turning off while I'm sitting at my desk reading. Commercial mmWave presence sensors like the Aqara FP2 cost $55-60, so the savings are significant.
Project 5: Plant Soil Moisture Sensor (~$8 total)
A capacitive soil moisture sensor costs about $1-2. Connect it to the ESP32's analog input, stick it in a plant pot, and you get a reading of how dry the soil is. Combine it with a BME280 for ambient temperature and humidity, and you have a comprehensive plant monitoring station.
I use this for my wife's fiddle leaf fig — it sends a notification to her phone when the soil moisture drops below a threshold. Before this, we'd either overwater or underwater the thing. Now it basically tells us when it's thirsty. Not the most critical smart home application, but it's one of those $8 projects that gets a smile every time the notification pops up.
Cost Comparison: DIY vs Commercial
Here's a real comparison of what I've built versus the commercial equivalents:
- Temperature/humidity sensor: $9 (ESP32 + BME280) vs $18-25 (Aqara WSDCGQ11LM) vs $35 (Ecobee Room Sensor)
- Door/window sensor: $7 (ESP32 + reed switch) vs $15-18 (Aqara MCCGQ11LM)
- Garage door controller: $10 (ESP32 + relay + reed switch) vs $30-50 (MyQ, Ratgdo, Meross)
- Presence sensor: $12 (ESP32 + LD2410) vs $55 (Aqara FP2)
- Soil moisture sensor: $8 (ESP32 + capacitive sensor) vs $30+ (Xiaomi Flora, ECOWITT)
If you build all five projects, you're looking at about $46 in parts versus $148-188 for commercial equivalents. And the ESPHome devices are more customizable — you can change update intervals, add multiple sensors to one board, create custom automations that run on the device itself, and flash firmware updates over WiFi whenever you want.
Limitations to Know About
ESPHome is great, but it's not perfect for every use case:
- Battery life: ESP32 is a WiFi device, and WiFi is power-hungry. Running an ESP32 on batteries gives you days to maybe a couple of weeks, not months or years like a Zigbee sensor. For battery-powered sensors (like a door sensor you can't wire to power), Zigbee devices are still the better choice. There are deep-sleep tricks that help, but they add latency and complexity.
- Requires Home Assistant: ESPHome devices work best with Home Assistant. They can use MQTT to work with other platforms, but the native HA integration is where the magic is. If you're not running Home Assistant, ESPHome is less compelling.
- Some soldering required: For many projects you'll need to solder wires to sensor modules and the ESP32 board. It's basic soldering — just connecting wires to pads — but if you've never soldered before, there's a small learning curve. A $15-20 soldering iron kit from Amazon and a YouTube tutorial will get you going. Some sensor modules come with pre-soldered header pins that you can use with jumper wires, avoiding soldering entirely.
- WiFi congestion: Each ESP32 device is one more client on your WiFi network. If you build 20 of them, that's 20 additional WiFi clients. Most modern routers handle this fine, but cheap routers with lots of IoT devices can start struggling. A dedicated IoT VLAN or a separate SSID on a mesh router helps.
Where to Buy Components
Amazon is the fastest option in the US. Search for "ESP32 dev board" and you'll find packs of 3 for about $18-20 (so ~$6 each). Sensor modules (BME280, DHT22, relay modules, reed switches) are all on Amazon too, though prices are 30-50% higher than AliExpress.
AliExpress has the lowest prices — ESP32 boards for $3-4, BME280 modules for $2, LD2410 sensors for $3. The trade-off is shipping time: 2-4 weeks typically. I order from AliExpress for bulk/non-urgent components and Amazon when I want something this week.
For ready-to-go boards designed specifically for ESPHome, check out the Athom pre-flashed devices on AliExpress — they sell ESP32 boards that come with ESPHome already installed, so you just power them on and adopt them in the ESPHome dashboard. They also sell relay boards, LED controllers, and smart plug modules pre-flashed with ESPHome.
Getting Help and Finding Ideas
The ESPHome documentation at esphome.io is excellent — every supported component has a page with wiring diagrams and example YAML configurations. The Home Assistant Community forums have a dedicated ESPHome category with thousands of project threads. Reddit's r/ESPHome and r/homeassistant are active too.
My suggestion: start with the temperature sensor project. It's the simplest build, the most immediately useful, and it teaches you the entire ESPHome workflow — editing YAML, flashing firmware, integrating with Home Assistant. Once you've done one, the second build goes twice as fast, and by the third you'll be designing your own custom sensor boards.
The ESP32 and ESPHome combination has genuinely changed how I think about smart home sensors. Instead of "can I find a product that does X?", I now think "I have a $6 microcontroller and a YAML file — I can just build exactly what I need." That flexibility, at that price point, is hard to beat.