When people talk about smart homes, the conversation often turns to expensive devices: branded smart plugs, bulbs, and sensors that cost far more than their "dumb" counterparts, all while being locked into a specific ecosystem. But if you're willing to get a little bit hands-on, ESPHome can save you a surprising amount of money.

ESPHome is an open-source project that lets you program ESP32 and ESP8266 microcontrollers, at $5 and $2 a pop, respectively, with simple YAML configurations, turning cheap, barebones hardware into powerful smart devices. Pair it with Home Assistant or any MQTT broker, and you can replicate (or even surpass) the functionality of commercial smart products all for a fraction of the price. These are some of the best and most interesting!

Whole-home temperature and humidity sensing

Collect temperature and humidity from everywhere

With some decent temperature sensors and either the ESP32 or an ESP8266, you can build your own temperature sensors for less than $5 each. You'll need to keep them wired to something for power, but aside from that, you can keep them chugging all day, all night, and have instant access to temperatures and humidity in your designated area in a way that you control, and for cheap.

Once hooked up, you can create all kinds of automations that are triggered by temperature changes, such as fans, thermostats, and anything else that you'd like to trigger and can link up to an automation hub. They're cheap, simple, and effective, and ESPHome makes the process of pulling data from a sensor incredibly easy. For example, this is all you'd need in your config in ESPHome:

sensor:
- platform: dht
pin: D2
temperature:
name: "Living Room Temperature"
humidity:
name: "Living Room Humidity"
update_interval: 60s

See what I mean? It's really easy, as ESPHome makes everything else for you. I've seen people utilize these in crawl spaces to monitor humidity, too, so that they know when to run a dehumidifier.

Air quality and CO2 monitoring

A guideline of CO2 and VOCs

While I wouldn't rely on one specifically for health reasons, a basic CO2 monitor built with an ESP32 can help you keep track of your air quality in your home. I use a Zigbee-based option that reports volatile organic compounds (VOCs), formaldehyde, and CO2 levels. I wouldn't trust any of the reported values as a completely accurate figure, but I do trust a rising value as a sign that I should open a window. I can get a notification when any of these go above a certain level, and I could automate the turning on of a fan or air conditioning system based on when these levels rise too high.

Again, it's not about the specific values, but we can measure a change in general in these values over time. You can spend more for an accurate sensor to attach to the ESP32, but even an accurate sensor will still be significantly cheaper than a high-quality $100 CO2 sensor from a well-known brand. So long as you have good airflow to the sensor, it'll be just as good. An SCD41 module from the likes of Adafruit, one of the best in the business, is $50. Combined with the $5 ESP32, you've just built a $100 device for half the price.

Water leak detection

Or water levels, instead

If you want to detect leaks, you can easily pair a water sensor with an ESP32 to pick up on moisture and trigger an automation to disable your water, turn off nearby devices, or even just notify you so that you can act on it. I use a Keyes water sensor, and it'll report a voltage depending on the amount of water that's making contact with the sensors. This can then be converted to a water level that you can use to keep an eye on something specific, such as the water level in something.

However, it's not just for water level, and you can use it for water leaks, too. For example, place it in an area that's ordinarily dry. if the value spikes, that's a sign that something is wrong. Of course, electronics and water don't particularly mix well, so be careful when setting this up to avoid damaging your ESP32, water level sensor, or even hurting yourself. If you want to set this up, here's a great thread with information on how to set something up like this for your home.

Like with the CO2 sensor, it's not about the exact reported value, but rather the change in general. If it's at 0v and suddenly spikes, you know there's suddenly moisture where there shouldn't be.

Presence detection

Motion sensors are easy to use

Credit: XDA

Want a cheap, easy way to see if someone passed a sensor? An ESP32 and a PiR presence sensor could be exactly what you need. A PiR sensor is nowhere near the best of the best when it comes to motion deteciton, but it gets the job done for less than a dollar in most instances. Just like you can do with a temperature sensor, it's very easy to define it in ESPHome:

binary_sensor:
- platform: gpio
pin: GPIO32
name: "PIR Sensor"
device_class: motion

That's all you need, and it'll start reporting back to Home Assistant with clear or occupied values. I recently built a Zigbee sensor with an ESP32-C6 using one of these, and it cost me about $5 for the entire thing. The beauty of an ESP32 is that you can take it apart and use it for something else if you'd prefer, so you don't always have to keep it as a motion sensor if you don't want to.

An ESP32 or ESP8266 is a great way to get started

If you want a cheap and easy microcontroller to build a new project, an ESP8266 is a great device to invest in. If you want something a bit beefier, the ESP32 is every bit as good and then some, while also packing support for practically everything you could ever want across the range of available chips. There's Zigbee and Thread in the C series and the H series, and there are wired options over Ethernet alongside all sorts of different hardware features. ESPHome makes it all as simple as it can be, and it's a great way to dip your toes in before getting more hands-on with the likes of PlatformIO or Arduino.