---
title: 'DIY Guide: 8 Essential Sensors to Give Your Smart Home Superpowers'
source: 'https://youtube.com/watch?v=sk7iLVKk4FE'
video_id: 'sk7iLVKk4FE'
date: 2026-07-01
duration_sec: 1387
---

# DIY Guide: 8 Essential Sensors to Give Your Smart Home Superpowers

> Source: [DIY Guide: 8 Essential Sensors to Give Your Smart Home Superpowers](https://youtube.com/watch?v=sk7iLVKk4FE)

## Summary



## Transcript

If you had one superhero sense, what would it be? Now Superman can shoot lasers out of his eyes. But can he turn on your lighting automatically?
Dr. Horrible can create a freeze ray and turn things to ice. But can he control his thermostat using Wi-Fi microcontrollers?
And I'd say something about Deadpool, but he's a Welsh fan, so he's perfect. This video is designed to introduce you to some unbelievably powerful yet super cheap components
that you can master to give you superhero powers. If you want the powers of heat, motion, light, sound, air, moisture, load and much more,
then you really need to watch this.
I want to give you a sharp introduction to all of these sensors so that you get that tingle of excitement of what you could achieve. I'm not going to be overly laborious and this isn't meant to be a spoon-feed tutorial feed
because there's masses of tutorials and guides already out there on all of these. These components are constantly getting upgraded, so what I want to do is give you a sense of how accessible this stuff is now. I want to give you the component names to then Google.
This is actually half a secret. Once you know that such a thing exists as a temperature sensor and it's called a BME 280 where are you my little lovely, then it's actually pretty easy to just Google BME 280
and get a detailed guide and videos on how to do everything on which ever chip that you're using. I'll start off fairly slowly to talk you through the process. By the end, I'll just be flying through at a high level as by then you'll be able to think for yourself.
I'll assume a few things. One, that you have home assistance set up. If you don't know what this is, then watch my other videos. You really need to get it set up.
Secondly, you should have an ESP32 chip and at least one of these sensors because, well, that's what this whole video is about. Other than that, you just need to pay attention.
Quiet down there at the back. Now, there are many variations of ESP32 chips. Some have cameras, others have LED screens on them and you can use these when you get a bit more experienced, but I'm going to use a basic one to keep things simple.
Let's start by getting the ESP chip running. Two things. First, plug it in. That's it. You've completed the first step. I'm being flippant, but I want to stress throughout this how easy this stuff has become.
This little chip is packed with useful components. It's Wi-Fi enabled, Bluetooth enabled, ultra-low power consumption and it has a surprisingly nifty little processor. What this means is that you've just created a standalone device
that you can put anywhere in your home. If you think what room you have a plug or USB socket in, well, it's kind of everywhere, isn't it? And even if you wanted to attach a battery or solar panel,
then the ultra-low power consumption makes these very effective and they can last a long time. So, what we have now is a little microcontroller that's running happily away. But it's doing nothing.
The rough equivalent of a PC that you've built and turned on, but there's no operating system. So the next step is to install ESP home. This again is super simple. Visit this page. I've put this link in the description as well.
Then click ESP home and follow the simple instructions. This installs ESP home as an add-on to home assistant. This is a central hub for all your ESP chips.
It doesn't just handle installing code the first time, but it enables Wi-Fi connections which then allow over-the-air updates. So, you can have 20 devices in your house. And if you change some of the code, you can just click to install instantly to them all.
You can also write code and debug it, validate code, check the logs, really everything that you need. We've now got a super powerful hub for our devices and a chip running away mindlessly.
What we want to do now is connect this chip to the hub and install a basic operating system to it. Once you've got your cable connected, you can just plug it in and click to add device in ESP home.
And it should take you through the steps. Clicking connect should pop up the USB port selector. And you can select your device there, well, then you're away. It steps you through the process of installing the initial OS on the device, like naming your device.
Once this is done, your device will be connected to your home Wi-Fi automatically, connected to your home assistant, and ready to rock forever more. You can disconnect it at this point if you want,
and all the updates you make will be done over the air. So we have now, in a matter of minutes, set up ESP home to act as a central hub for endless devices, and connected your first ESP32 and installed the basic software.
We're basically done. The next step is about connecting up sensors. So let's go through eight of the most common to show just how easy it is. Let's start heating things up with a temperature sensor.
Wouldn't it be cool, pardon the pun? If you could measure the temperature fluctuations around your house every second of the day, imagine being able to trigger devices to turn on and off based on temperature thresholds.
Well, that's super cheap and super easy. Let's start with the vulnerable DHT22. If you Google each of the sensor names in this video, you'll see just how cheap they often are.
It'll shed new light on the markup you pay in all these commercial devices. The DHT22 is a very simple temperature sensor, and a great place to start. It has three pins, power, ground, and data.
The first two are just power the device, and the last is how the sensor readings are sent to ESP home and home assistant. Now to wire this up, you just need to connect each pin to the right place on the ESP32.
It's pretty simple. The power goes to the power, the ground goes to the ground, and the data goes to one of the data pins. There are loads of pins on each chip. This gives you the ability to create even more complex sensors,
like if you wanted a single chip that monitored temperature, light levels, noise and more, well, you just connect it to different pins for each data feed. But we'll keep things simple for now.
I've picked GPIO23 for my data. You need to remember that for your code later. Almost all ESP32s have the pins written on the board,
but you can also look up your model online to see all the diagrams and guides. So coding time, this is where the penny may drop on just how awesome ESP home really is.
It's already handled the vast bulk of the code for you, so you don't need to worry about Wi-Fi configuration or Bluetooth management, energy settings, encryption and all that stuff.
You just need to code the sensor, and that is as simple as you could imagine. We write sensor to let it know that the sensor is attached. Then we confirm the platform as DHT for this sensor, as it's a DHT22.
All this is available on the ESP home site, and they do a great job of giving sample code for everything. Then we put in the pin that it's connected to. As I said earlier, I'm using the GPIO23.
We put in the model number so it knows how to interact with it. This is all the code you need to set up your sensor. Now, to create sensor values that get tracked in home assistant, we just type what they are.
So, temperature with a name of outdoor temperature. And we can also add humidity, which this sensor tracks in the same way. Now, I'm keeping this code super simple, but one more thing we'll add is the update interval.
This is handy as it naturally will affect the amount of data that flows into home assistant and the energy use of the device. That's it. You've created your first sensor.
You now just click to install it, and it'll do all the hard work for you. If in future you wanted to change the frequency, name, sensors or anything, you can just edit it from here and broadcast the new code over the air.
Cool, eh? Let's quickly jump into home assistant, and you'll see under integrations the new sensor is already appearing. Clicking on it and you can see the values coming through.
Oh, exciting! And finally, let's jump into a dashboard page. Create a graph and bang! We've got a detailed sensor that tracks the temperature and humidity constantly.
And how easy was that? We can use this sensor easily to trigger anything we want. Change light colours, play sounds, turn on air conditioning,
or simply gather the data to build your knowledge of temperature fluctuations. Final point, I'm deliberately picking the cheap components for each of these demos to make it as accessible as possible.
There are definitely better sensors out there with improved accuracy. The temperature accuracy of the DHT22 is fine for general sensing, and the humidity is actually a proxy sensor by inverting the temperature.
For most use cases, I'd actually recommend the BME 280 as its much higher accuracy is really handy. There's also the newer BME 680, which is even better, but naturally the cost goes up a little each time.
So just pick what suits you use case. You now have to install a temperature sensor. That's my little acolyte. I can see you crave more.
So let's get moving with motion sensors. I'll assume you know now how to set up the ESP32 chip, and we can just jump directly to the wiring and the coding.
This is the HCSR04. They're again very cheap, and it works by sending ultrasonic waves out and then measuring the response times. Because there's two of them, they can work much like two eyes do,
and judge distances by the difference in response times. The wiring is very simple. Coding is very similar again. We just have a trigger pin to send out the pulse and an echo pin to read the waves bouncing back.
Other than that, it's simple, eh? You'll already know what the update interval does. This is worth considering carefully for your use case. If you want a motion sensor for a room, you might actually want it to be quite slow,
so it's not hammering backward readings all the time and triggering on and off. If you want something like my hands re-light music volume controller, or then you might want it to be much faster to allow a smooth control of light levels.
This is where NM wave sensors come in. They're very similar, but their sensitivity is exceptional. Sub-millimeter as the name suggests.
So they will detect you in the room as long as you're breathing. And if you're not, well, it might be a fitting end for your smart home to fade the lighting and music in time for you leaving this mortal coil.
Katie has been deactivated. Oh, this is quite dramatic. Let's now grant you the power of light with lighting sensors. For this, we'll use a BH1750,
which is a little sensor that happily detects light levels. You'll be coming in ESP Pro now, so you know what to do. The code is very similar. Just define the name that you want for your sensor,
the update interval. That's it. There's an option of value for the address that you can set if there are any issues. By default, it sets it to 0x23.
But if you have any problems, just add this and set to 0x5c and you'll be sorted. Again, all this is covered in brilliant detail on the ESP home site.
Save, compile, and publish your code. And we now have a light sensor that you can use to do all sorts of cool things. Again, there's loads of even better sensors.
The APD-S996O recognizes colours, so you can have it trigger a different action based on the colour of the room. I'm not done with you yet. I want to hear you squeal with excitement.
So I can measure it with my sound sensor. Let's use the KY038, a nifty little sensor that measures sound. I don't even need to tell you now what to do.
You know the drill and the code is very familiar. Only thing to call out is the attenuation variable. Without getting too nerdy, because the ADC or the analog to digital converter on the ESP chip is sensitive to the input voltage,
you need to cater for this. As you've got a 3.3 volt input, you just need to enter 11 decibels, and that's it. And as you're getting a little more comfortable, I've added some filters to the code.
These basically let it smooth out noise levels. If you imagine a normal sound wave of, say, you talking, it's very noisy waves as it's literally noise.
And let's say if you were in a dungeon, then the human ear would consider it noisy, but this sensor would more accurately describe it as quiet, punctuated by the sound of whips and screams until final silence.
So to make it more useful, you want to average it out a little, to give you a general level of noise. That's it. Now you have a sensor in your house that monitors the sound levels.
You can also use it as a simple burglar detection for everyone. Set ninjas. Now I can hear you panting with anticipation. But is the air your breathing clean or dirty?
Now let's think about an air particulate sensor, things like the HM3301. This has a little fan that sucks in air, blows across a sensor and detects PM1, 2.5 and 10.
The code is super simple, the wiring is super simple, and you're sorted. I will paste the code in the description for each of these. You've now got a sensor that detects dust levels,
so let's you know when you need to hoover or if you suffer from hay fever. If you have a workshop, it can alert you to dust levels being dangerous. There's so many cool uses of these sensors,
but most importantly it gives you the data about your environment, so you can understand it better. Okay, hopefully that's got the juices flowing. So why don't we measure them?
Unmoisture sensor. Imagine every plant in your house being able to scream at you when it needs watering. Or a dashboard that shows all the moisture levels,
the temperature in the rooms and the humidity levels. To do this, you just need one of these dudes, called a capacitive soil moisture sensor. There are loads of types,
but I'd go with a capacitive sensor as they're less prone to corrosion than the resistive types. And naturally, as they're in soil and water, it'll be getting a little bit exposed to that.
The code is simple. You just need to name the sensor and pins as always, and set the attenuation for your device. You'll notice two filters. First, the calibration.
As the device doesn't know what you're going to use it for, you need to set the values for what wet and dry means. If this was measuring whether your pond was drying up, then wet would be very wet,
as it would be completely immersed in water. If it was measuring soil moisture, well, then wet would be a much lower value. You can naturally set these values in home assistant too,
but it's handy to control them from the device itself sometimes. You can test the values by checking the logs in ESP home, as you use the device, or just use home assistant to read state values for the sensor.
I've also added a median filter as another example of how you can filter out noise. This basically takes a median size of three readings and will send the new median every time it takes a reading,
thus smoothing the results. And that's it. You can now measure moisture super easily. But let's talk about one more example. Where you start to get components like B parasite.
This is where you start to see that some options combine things. This nifty little open source approach monitors moisture, temperature, humidity and light levels,
and it all gets powered by a little battery that can last for years. So you could stick a bunch of these in your garden beds and have unbelievable details of how your plants are doing all in one.
Okay, the HX711. This is a load sensor. The code is super simple and just needs a bit of calibration. So you'll need a precise weight.
Say, put a 1 kilogram weight on it. And if it reads 810, then put that number into the filter. This can be used for lots of things. Obviously, the scale is handy.
Again, you can get even more precise devices on your use case, but you could easily have a device that monitors the amount of coffee beans left in your pot or sense when someone steps on your door mat
whether someone is on a chair or trigger when a precious jewel is lifted from its place and so on. NPR121, capacitive touch sensor. These detect your touch.
Just let your phone screen. Different models have different ranges, but it's pretty cool to create a button on a material that senses through it. A device that triggers when you tap the material in different places.
And finally, you're very quickly see how you can start to put these sensors together into combined all in one units. As you add more, inevitably it gets more complicated,
but it's all achievable. Companies like Apollo Automation are great examples. All of their stuff. So if you want to quick off the shelf solution with an absolute battery of sensors already available, go for it.
You may think that this is all now easy, and in many ways it is, but there are three tips I'd like to share to save you hours of head banging. Things will of course not work sometimes,
but it's amazing how many of them will be down to one of these three reasons. Number one, connect directly to the device running ESP home if you're struggling.
This takes out lots of potential issues with your home network setup, device authentication and more. Number two, check your USB cable. I know you're sure it's a data cable, and it's definitely working,
but you'll be amazed at how often this is the cause of problems. It's that chaos of USB standards again. Top tip. Get one of these.
Just plug the cable in two places, and bang, it tells you exactly what cable you've got. Number three, look at the data sheet for your exact microcontroller and sensor.
Just google the name of it. Again, you'll be amazed at how often something changes with a new model and that's the source of your problems, and you just need to change the data pin you're using or something similar.
So that's it. You now have the power, but promise me you'll only use your powers for good. I hope this video has helped demystify some of these chips and sensors,
and you're able to fly off into the world to make great things. I'd like to thank the real superheroes of this video who was soaring past my head. My patrons and YouTube members.
If you'd like to see more videos, then think about joining. Links in the description as always. Oh, and many thanks to all of the wonderful developers of ESP home
who do such a great job in helping make the world of microalertronics accessible to everyone. Who else?
