Let's build a room sensor - Part 1 - Temperature, Humidity, and Bluetooth
Summary
TLDRThis tutorial covers the basics of creating a room sensor using ESP development boards and various sensors, including Bluetooth temperature and humidity sensors (DHT22), light sensors (BH1750), and presence detectors. The video details the setup, pin configurations, and coding in ESPHome, emphasizing practical applications like gas sensors for kitchens and distance sensors for garages. The tutorial aims to build a comprehensive room sensor, with future videos adding more features and sensors. It also includes a demonstration of integrating the sensor data into Home Assistant for monitoring room conditions.
Takeaways
- 📡 The tutorial covers the basics of using a room sensor with various devices.
- 📶 You need a basic setup for devices as described in the ESP Foundation tutorial.
- 🌡️ The focus starts with Bluetooth temperature and humidity sensors, specifically using a DHT22.
- 🛠️ Additional sensors like light, CO2, TVOC, and movement detection will be added in future videos.
- 💡 The tutorial will also explore adding touch screens to control lights or open doors.
- 📋 The bill of materials includes ESP development boards (ESP32 or ESP8266), suitable USB cables, and capacitors.
- 🔧 The DHT22 sensor is preferred over the DHT11 due to better temperature and humidity range and resolution.
- 📐 Important differences between DHT11 and DHT22 include temperature range, humidity range, and sampling period.
- 📝 The video provides guidance on wiring and coding for the DHT22 sensor.
- 🔄 The tutorial uses Home Assistant and ESPHome software, detailing the setup and configuration process.
Q & A
What is the primary focus of this tutorial?
-The tutorial focuses on setting up a room sensor using various sensors, including a Bluetooth temperature and humidity sensor, with the aim of creating a comprehensive room sensor system.
Which temperature and humidity sensor is being used in the tutorial?
-The tutorial uses the DHT22 temperature and humidity sensor.
What additional sensors are mentioned for future videos?
-Future videos will include sensors for illumination, eCO2, TVOC, movement detection using a PIR sensor, and presence detection using a millimeter wave sensor.
What are the primary differences between the DHT11 and DHT22 sensors?
-The DHT11 has a temperature range of 0 to 50°C and a humidity range of 20 to 90%, with a 1% and 1°C resolution. The DHT22 has a temperature range of -40 to 80°C and a humidity range of 0 to 100%, with a 0.1% and 0.1°C resolution.
What is the purpose of the 10 microfarad capacitor mentioned in the tutorial?
-The 10 microfarad capacitor makes it easier to upload firmware via the USB port.
What software is required for this project?
-The required software includes Home Assistant and ESPHome.
Why is it important to check the pin assignments for each ESP model?
-Pin assignments vary between different ESP models, and using the wrong pin configuration can damage the microcontroller.
What are some use cases for the sensors mentioned in the tutorial?
-Use cases include detecting gas in the kitchen, using a distance sensor in the garage for parking, and monitoring room conditions such as temperature, humidity, and presence.
How does the Bluetooth proxy function in the tutorial?
-The Bluetooth proxy extends the Bluetooth range of the Home Assistant machine, allowing it to communicate with Bluetooth devices beyond its direct range.
What should be considered when using the Bluetooth Low Energy Tracker Hub?
-The Bluetooth Low Energy Tracker Hub is processor-intensive and can interfere with other functionalities like the web server, so it should be used sparingly and only when necessary.
What is the purpose of having unique IDs for sensors in Home Assistant?
-Unique IDs allow for manipulation and changes within Home Assistant, making it easier to manage and interact with the sensors.
What are the steps to add the DHT22 sensor to the ESPHome configuration?
-The steps include adding the DHT22 sensor to the GPIO pin (e.g., GPIO26), defining the sensor platform in the ESPHome configuration file, and specifying the update interval.
What additional features are planned for future tutorials?
-Future tutorials will cover adding a light sensor, more presence and movement sensors, and building specific sensors for different rooms like the kitchen and garage.
What is the benefit of using i2c in sensor configurations?
-Using i2c allows for flexibility and chaining of multiple sensors, making it easier to expand and customize the sensor setup.
How can the data from the sensors be displayed in Home Assistant?
-Data from the sensors can be added to the Home Assistant dashboard, where it can be visualized using various types of cards, such as temperature and humidity gauges.
Outlines
🏠 Introduction to Home Automation Sensor Tutorial
This paragraph introduces a home automation tutorial series by Automator South Africa. It covers the basics of setting up a room sensor using various devices, starting with a Bluetooth temperature and humidity sensor, specifically the DHT22. The tutorial will expand to include additional sensors like eCO2, TVOC, movement detection, and potentially a touchscreen for control. The presenter intends to create a comprehensive room sensor setup that viewers can customize. They also invite viewer suggestions for additional sensors and remind viewers to engage with the content through likes, subscriptions, and comments.
🔍 Exploring Sensor Capabilities and Differences
The second paragraph delves into the specifics of the temperature and humidity sensors, contrasting the DHT11 with the DHT22. It highlights the broader temperature and humidity range of the DHT22, as well as its higher resolution and slower sampling rate. The paragraph also emphasizes the importance of consulting pin assignment diagrams for different microcontrollers and discusses the differences between the DHT11 and DHT22 in terms of sensitivity and range. The presenter plans to replace the DHT sensors with a BME280 and SHT40 to demonstrate I2C capabilities.
🛠️ Setting Up the DHT22 Sensor with ESP Home
This paragraph describes the process of setting up the DHT22 sensor with ESP Home. It covers the pinout connections required for the sensor, including VCC, data, and ground. The presenter discusses the use of a 10 microfarad capacitor to facilitate firmware updates via USB and the choice of GPIO26 for the data pin. The paragraph also includes a brief mention of coding in ESP Home, with an emphasis on the importance of using the correct documentation for the microcontroller being used.
📡 Discussing Bluetooth Integration in Home Assistant
The fourth paragraph focuses on the integration of Bluetooth in Home Assistant. It explains the functionality of the Bluetooth proxy and Bluetooth Low Energy (BLE) tracker hub, including their roles in extending Bluetooth range and tracking devices. The presenter warns about the intensive processor usage of the BLE tracker hub and advises against its use unless necessary. The paragraph also touches on the use of the proxy for monitoring devices like the Mopa Pro gas bottle fill monitor and the importance of using the web server for debugging and additional functionalities.
🌡️ Adding the DHT22 to ESP Home and Testing
In this paragraph, the presenter adds the DHT22 sensor integration to the ESP Home configuration. They provide a code snippet for the DHT platform, specifying the GPIO pin, sensor name, and model. The update interval for the sensor is set to 30 seconds. The presenter then demonstrates an Over-The-Air (OTA) update of the ESP32 device and confirms that the sensor is functioning correctly by displaying the temperature and humidity readings in Home Assistant.
📊 Creating a Dashboard for Sensor Data
The final paragraph discusses the creation of a dashboard in Home Assistant to display sensor data. The presenter demonstrates how to add cards for room temperature and humidity to the dashboard, using the data from the DHT22 sensor. They provide a step-by-step guide on configuring the cards, including setting the minimum and maximum values and choosing the display format. The paragraph concludes with a preview of the dashboard and a reminder that future tutorials will cover additional sensors and functionalities.
Mindmap
Keywords
💡ESP32
💡DHT22
💡Home Assistant
💡Bluetooth Proxy
💡BME280
💡I2C
💡Pin Assignments
💡ESPHome
💡Capacitor
💡PIR Sensor
💡Dashboard
💡Humidity Range
Highlights
Introduction to Home Automator South Africa tutorial covering the basics of a room sensor setup.
Explanation of Bluetooth temperature and humidity sensors, specifically the DHT22.
Outline of additional sensors to be covered in future videos: illumination, eco2, TVOC, and movement detection using a PIR sensor.
Plans to add a screen and touch functionality to switch on lights or open doors.
Customization of sensors for specific rooms, like gas sensors for the kitchen and distance sensors for the garage.
Detailed list of materials needed: ESP development board, suitable USB cable, 10 microfarad capacitor, breadboard, jumper wires, and DHT22 sensor.
Explanation of the differences between DHT11 and DHT22 sensors in terms of temperature range, humidity range, and resolution.
Importance of correct pin assignments for different ESP boards and how to find manufacturer pinout diagrams.
Steps to prepare the breadboard and wiring for the DHT22 sensor.
Introduction to YAML coding in ESPHome for setting up the DHT22 sensor.
Explanation of Bluetooth proxy and Bluetooth low energy tracker hub functionalities in Home Assistant.
Compilation and installation process of the ESP32 with the new YAML code.
Verification of the DHT22 sensor data in Home Assistant dashboard, showing temperature and humidity readings.
Plan to add a light sensor in the next tutorial and details about future quick tutorial videos.
Reminder to like, subscribe, and hit the notification bell for more tutorials.
Transcripts
[Music]
hello hello hello and welcome to a home
automator South Africa tutorial today
will be covering the basics of a room
sensor to be able to successfully
complete this tutorial you will need the
basic setup for all devices my ESP
Foundation tutorial today we will start
with the Bluetooth temperature and
humidity sensors now the temperature and
humidity sensor is the same device uh
it's going to be in my case a
dht22 I will talk about it a little bit
more a little later on in this video
after that we'll be adding some more
sensors
elimination
eco2
tvoc movement DET detection using using
a p sensor presence
detection with a millimet wave
sensor we might add a screen
and if I have time touch to the screen
to be able to switch on lights or uh
open doors something like that I will
add all of these sensors over the coming
videos I don't know when these videos
are going to come out but I am going to
try to make them as regular as I can at
the end of the project I intend to have
a full room sensor that works for all of
us you can subtract from it you can add
from it but also what I will be doing is
at the very end of this is add some
specific for example in the kitchen you
may need a gas sensor for either natural
gas or
LPG and we will work on building such a
sensor for the kitchen in the garage you
might want to have a distance sensor for
when you park we will then build one of
those as well so all of this is in the
planning and there will be others I'm
sure if you have any ideas of what we
could do for room sensor please don't
hesitate put it in the comments below I
read all of my comments I reply to all
of my comments
a little self- serving reminder don't
forget to like subscribe and hit that
notification Bell also all of my
tutorials have time codes or chapters
attached to them
below before we start building I'd like
to give you the bill of
material we we're going to start with
the ESP development board mine is an ESP
32s board but any ESP
8266 or 32 will work you might have to
readjust some of the pins a suitable USB
cable in my case my USB cable is a micro
USB a 10 microfarad capacitor now this
is not required but it makes it easier
to dump the firmware using the USB port
and I'll explain to you later why a
brakeboard some bre brakeboard jumper
wires you shap breadboard jumper wires
this is an
option this is optional but it will make
your life much easier easier I
promise and obviously either a DHT 11 or
22 temperature and humidity sensor
module you can use a
dhd1 I will be using a dht22 and I will
explain to you why later in the coming
videos we will also
add a
bh1750 light
sensor and we will talk about the
advantages of using i squ c or
i2c
then we'll add a gp3 a
quality s sensor
module uh this sensor module is the only
one that I could find in South Africa at
the time of recording there are IDs they
all work pretty much the same so if I do
this one you'll know how to do the
rest a p sensor for movement
detection then we will talk talk a bit
about universal asynchronous receiver
transmitter or
art and the protocol behind it and then
we'll add an LD
2410 C presence radar sensor that is a
tricky one so it might be longer than
the
rest um and at the end I will replace a
DHT 11 or 22 with a BME
280 and an sht 40 just to show you what
we can do with
i2c um i2c allows us quite a lot of
flexibility and chaining of
sensors software wise the requirements
are very simple we need home assistant
and we need espo that is it nothing
else so instead of carrying on and
talking about things how about we start
building before we carry on I'd like to
talk quickly about something that's
relatively
important for each device that we are
going to use be it an ESP 32 32s 32 S2
C3 or an
esp8266 there are pin assignments to
them and these are usually done for
manufacturer for example an ESP 32 cam
will not have exactly the same pin
assignments as a ESP 32 D1 mini and the
D1 mini would not have the same pin
locations as another esp32 to to find
which pins you have for the given ESP or
any other microcontroller you will have
to find the manufacturer pin out diagram
and this is what we have in front of us
the binard
diagram this is the one that I use which
is the espb
32s from from AI thinker this is the uh
the the board uh that we are going to be
using right through and that we have
already been using in previous tutorials
I will leave a link below with the
address of where you can get this
diagram and a little bit more about this
specific node
MCU today we will be using GP
io26 which the arrow is pointing out
right now okay I think this was uh
something that was very important you do
need to get the documentation for your
MCU and not all mcus have the same pin
diagrams I got CAU out thinking that uh
the node MCU and another MCU had the
same pin assignment at the same place
this is a good way to blow up one of
your
microcontrollers before we continue I'd
like to speak about the differences in
between the DHT l and the
dht22 although you can use either of
them there are major differences to them
not in the wiring but in their
sensitivity and in their range so to
give you a fair idea of what the
differences are the temperature range of
the DHT 11 is from 0 to 50°
C whereas the DHD 22 is from - 40 to 80°
C the humidity range for the DHD 11 is
in between 20 and 90% whereas the TW DHD
22 ranges from 0 to
100% additionally there are some
resolution changes between the
two for the humidity and temperature the
DHT 11 has a 1% one degree
step whereas the
dht22 has a 0.1% step on
both lastly and possibly not as
important but worth
remembering is the sampling
period the dht11 can sample at one time
a second whereas the
dht22 two seconds to refresh so you
cannot request the data from the
dht22 faster than that now the ESP home
libraries takes care of all of this so
you don't have to worry too much about
it I just wanted to make sure that you
understood the differences between the
two now in this project you can use
either and the pin outs are exactly the
same so let's move on to that
the first pinout I'm going to talk about
is the VCC or power
pinout for the
dht22 the power can be in between 3.5
volts and 5.5
volts the second one is going to be the
data now we are getting serial data out
of this it is a digital
output so we do not need an analog pin
and the is reason why I chose
gp26 the last pin is ground obviously
it's going to go back to the ground now
you're going to see all of this in more
details shortly when I show you how to
wire
it as you can see I have prepared the
brakeboard with uh all we need uh you
can see the dht22 this white little uh
block over there so let me just explain
to you what I've
done I have hooked up the
VCC to the positive
rail the ground to the negative rail
these rails run this
way uh whereas these rails run this way
okay so the next one that I need to talk
to you about is the 10 microfarad
uh capacitor which is only there so that
we can actually use the serial
in without having to push any of the
button particularly this button over
here the data the serial data from the
dht22 as you can see comes into GPO
26 let's go and do some code and see if
all of this
works
here we are we are ready to do some yaml
code in ESP home but before we do some
things that I wanted to point out the
first thing is that our version
of Home assistant is now 20
24.
3.0 and the second one is that our ESP
home version is currently 20 24.2 do2
both of them have changed during the
time that I Was preparing for this
recording and uh I thought I would tell
you where I am now so that we are on the
same
footing okay so we can go straight to
spom and I would like to show you a
little something I'm going to go into
our last tutorial regarding SP home and
I am going to scroll all the way down
and you will see here we have 202 lines
why have I done that well I want to show
you this one now this is a brand new
device I primed it like I primed the
original one that I did in my first
tutorial where I show you how I prepare
my ESP home
devices and you will see that this
device
also has
202 lines and that's because both of
them are using exactly the same code at
the exception of what is in the
substitution variables I have just
change the name and put a new IP address
we can move on and start doing some
code the first thing that I'm going to
do is I'm going to go just under the
Wi-Fi and this is because I like to have
some order Wi-Fi is a communication
system and so it's Bluetooth so I am
going to put bluetooth under Wi-Fi I
have this prepared and it is in in
another the screen so I'm going to copy
the code here and I am going to paste it
right for
you
um I know that caching will give us some
problems and I also know that
um
my code is not quite correct so I'm
going to go and fetch this device
internal
name and I am going to change the device
name to device internal name why does
the cach service doesn't work well the
cach service is a ESP IDF function just
so that I explain to you there are two
ways of compiling
there is the Arduino framework or the
ESP IDF framework oddly enough as I
think I explained in the previous one
the Arduino FR framework for
esp32 actually leverages entirely from
the ESP IDF framework now let's go
through Bluetooth I am going to just
scroll it a bit up so that we can all
see it here we are uh the Bluetooth
proxy as you know very well know extends
the home assistant machine's Bluetooth
abilities Beyond its range so wherever
you're proxy it plays the game of
switching from the BL whatever the
Bluetooth signal is on the one side and
outside of the range of the home
assistant machine and it forwards that
to the home assistant machine
or the other way around so it's
basically like having a long cable with
a Bluetooth dongle at the end to extend
the range of Bluetooth that is all well
and fine and it's not a problem the next
one is the Bluetooth low energy tracker
Hub the Bluetooth low energy tracker Hub
is very intensive on the
processor so we need to use this
sparingly in fact I would even
discourage you from using it unless you
know exactly that you're going to need
it in that
position and that's because you lose the
ability to do other things uh web server
being one of
them the uh tracker and the web server
at the same time do not work I have
tried on many occasions and I end up
with a microprocessor that just reboots
and reboots and boots or boots randomly
for no reason whatsoever if you are
going to have a Bluetooth device or many
Bluetooth device in a room sure use it
if you're not going to have any
Bluetooth device in that room comment it
out rather have the web server it's far
more useful and I think I explained why
it is useful it allows us to debug but
beyond all of that it also allows
further things
which I will talk about in one of my
quickies it is related to the way that
we can connect an ESP 32 ESP home device
to a new network so the Bluetooth proxy
is active equals true means exactly what
it says here it is I'm a proxy I'm
active use me the Bluetooth low energy
tracker Hub at
okay fine I'm going to scan for stuff
that I can track that announces itself
and uh I'm going to do that at every
1,100 milliseconds or 1.1 second why
would that be useful I have a mo M Pro
Bluetooth device which allows me to
monitor my guas bottle fill so I know
when I get too low
about 10% it actually sends out an alert
to me through home assistant it is a
Bluetooth device and it is outside of
the range of my home assistant server I
use it there I also use the same uh
esp32 to monitor any gas leak around the
bottle there is a good case for that I
am going to stop about Bluetooth at this
point in time we will treat Bluetooth
device is in more details especially I
think the the mopa pro and I'm hoping
I've got the name right because it is an
interesting device I am going to compile
and install this so let's go to install
and because it's been primed with my
code already I know that it has Wireless
ability a few moments
later we are waiting for the esp32 to
respond and there we are
it is responding I would like to show
you that the blle is indeed installed
and you can see it right
there and
uh there we are we are now reading data
from our
ESP now let's talk about adding the
dht22 I think that we I've covered the
dht22 in uh enough details previously so
all I'm going to do is add the code and
explain to you what the code does I am
going to go down and uh go all the way
down to my sensors uh area there it is
sensors sensors area I am going to do
some space for
us and uh go back a little bit and just
paste my code so so here is the code I
like meat code so I will do this okay so
the platform is
DHT
the gpio that we opted for is a GPO
26 and I chose that one for a good
reason and I will be honest with you I
can't remember why then after that it's
simply temperature and as you see name
temperature
ID and humidity name humidity and an ID
now I have a tendency to put IDs to
everything and that's because in home
assistant if you've got an ID you can
actually do some manipulation and
changes inside of Home assistant uh that
you can't do if you're not if you do not
have a unique
ID okay the model is a
dht22 yes if you use a DHT 11 it would
be dht11
and
lastly update interval is the update
interval that I set at the top of the
file now just to show you what that
update interval is set at right now it
is 30 seconds okay let's go back over
there and this is everything we need to
do just to get a dht22 to work I will be
honest with you I'm going to cross
fingers and touch wood and hope that it
works as I said the esp32 is primed and
we can do an
OT and ply and here we go it's going to
be much faster than the last one now the
last one took a little bit of
time uh it had to download certain
things and it had to do a few other
things like compile everything this time
we only compiling two
so it should be pretty
fast there we are and it is uploading it
a few moments
later now we are waiting for the device
to respond back after
reboot and here we
are okay I am going to scroll down a
little bit so that you can see where the
DH T is being
initialized and we're going to go down
and we are starting to get data so I
must of pray to the right computer
guards and we are getting actually 20
28.1 Dees and
40.3% humidity which is highly likely we
have a storm outside and uh it is
raining and uh the temperatures right
now are very high okay and yes it is 1
p.m. that covers everything I wanted to
show you inside of ESP home so I am just
going to go stop I am going to CL
close and our device is indeed online
and I get a notification a new device
has been
discovered I am going to dismiss it
because I do these things I'm going to
go to settings device and
services and you you are going to see oh
I was talking about the mo mopa check
and it is available to me right here
right now and through that uh Bluetooth
proxy uh it is a Bluetooth one it is
sitting on the other side of the room of
the wall so obviously it will pick it up
the one that it did not pick up is the
ESP home device that I want us to use I
see why I Prime the ESP Home Room sensor
device previously so we're going to go
into it and as you can see the humidity
is appearing the temperature is
appearing and all of the other things
that we have set up is appearing so how
do we go about putting that into the
dashbo I'm not going to go into funny
things today um I will have a separate
video regarding how to build a dashboard
with yl I know there are new function
ities drag and drop that was introduced
in this version of Home assistant I'm
still a bit old style I like the control
that I have when I do things by code but
just to demonstrate how well all of this
works we are going to just go add to
dashboard and this is what it will look
like and we are going to just add it to
the
dashboard if we come back to overview
here we are the this is the data that we
have right now we do not have any fancy
I don't think we've got anything fancy
that we can do with it a little longer
than a few minutes
later here we've got a we've got one um
and uh right now that's a signal sensor
but what we want is let's use the temp
oops let let's use the
temperature the the temperature the room
temperature sensor and and the units and
everything else is good we are going to
put a
Time ah if I could spell
temp right
here and I guess we should say GR in
front uh the unit is um degrees
Centigrade we're not going to change
there the minimum um I'm not going to
change the maximum uh let's let's put
the minimum at zero because it's a room
temperature and the maximum we are going
to put at 40 what do you think so we can
display it as a
needle go as a needle gauge I don't like
that severity no that's fine okay so we
are going to save that and we are now
with a room temperature of
22. oh
28.2 uh to I wonder if no it's not there
yet okay and we can add another card
same one if I can find it again here he
is and we are going to take this and we
are going to say humidity and humidity
obviously
humity and as I was about to say
humidity starts at zero and the maximum
is 100 and we're going to save that and
now we have both room temperature and
room humidity available to us on the
dashboard I am going to wrap off for
today and the next one I will be adding
a light sensor and it is going to be a
quicker in fact the next few are
probably going to be all quickies until
I do presentence and U movement which I
will possibly do at in in one single
tutorial anyway I think we've covered
this very well if you liked the video
obviously please do not hesitate to
click the like button if you want more
of these hit that subscribe button and
if you want to be notified hit that Bell
icon this is Pascal signing off until
the next tutorial have a great
[Music]
one
Посмотреть больше похожих видео
5.0 / 5 (0 votes)