Hi and welcome to a new section in this course, in this section, you learn how to use a variety of
senses, typical senses that you are unlikely to want to connect to your especially to start starting
this lecture with a look at the THC 22, since this is so not only is very popular, obviously you probably
have one in your choice already, but also because the ability to moderate Python firmware already comes
with a driver for this sensor.
So there's nothing else that you would need to import or to install.
And therefore it makes it a very good choice for it being our first sensor.
So I have connected this sensor on my breadboard to remove it.
We can take a closer look.
So I've got my sensor looking at it from the front where the grill is.
Number one is power.
I've connected that to three point three volts power.
To the other side you've got ground pin number.
It goes to ground, of course, a pin number three.
This one right here is not connected to anything.
Just leave it floating.
And then pin number to this pin is the pin that I have connected it by this jumper wire to chip here,
four to one that I have connected it.
Just knowledge that is.
Not in 04, actually put in 18, so it's fixed it on the fly right there.
OK, so I'm going to plug the sensor back on my breadboard and have a look at the sketch.
Now, I've got some information on how to connect your sensor.
He could use DHT 22 or DHT 11 for this experiment.
Either one will work and the driver for either one is available in the market, both in firmware.
I've got information about this right here.
Might start with this.
So go to this.
You're real.
And we'll take you to the micro python documentation.
And I'm looking at the E.S.P three two quick reference.
And down here you'll see the DHT driver.
You can choose between the 11 or the two.
Just tell it which pin your data pin is connected to, which Appio, you terrapin of the sensor it's
connected to, and then you can take a measurement by calling the measure function and then you can
read out temperature and humidity by calling the appropriately named functions very easy.
So in my sketch, this looks like that I have imported the module, importing the PIN and Taimur functions
from the machine module.
This is where I create my DHT 22 object.
And then as you've learned in previous lectures, I'm using a timer.
I've given it a period of 5000 milliseconds or five seconds.
Is this since I was quite slow and it's a couple of seconds to recover.
Each call takes a couple of seconds to complete.
So five seconds seems like a reasonable amount of time to wait before the next measurement.
And every time this clock ticks or every time this clock expires, I call the take measurement ISO function
right here, which calls the measure function.
And then I'm putting out temperature and humidity like this very easy.
So let's try this out.
Right now, I'm looking at this script as stored on my computer file system, so I am going to save
a copy.
And you can see that my security is connected, but it does not appear in the final steps.
I'm just going to click on Stop.
To wake it up and make this connection, that's why I got confused, I thought that it was a connected,
but it was so here I am going to now save a copy to the Michael Python device.
And I use the same name, DHT p y.
Let's try this with lower case.
OK.
And.
Play.
Wait for five seconds.
And there's a first measurement appears here.
Right.
Out of curiosity, let's see if the plot works.
So the plot doesn't work because it can't figure out the values here that are coming out.
I'm just going to turn this off and stop the execution and stop putting.
And I'm just going to move.
The values that save.
And start again.
Medicare now the employer can show the two values, GraphicLy.
Of course, I'm just sending through the numbers instead of numbers, followed by the symbol of the
value, I'm going to play around with a product as well in a later lecture.
Well, we'll have a look at the accelerometer.
All right, good.
I'm going to put the symbols for the units back because that's how I'd like to keep my sketch.
Right.
So this was quite easy, as you can see, because the driver is part of the firmware.
In the next lecture, I'll show you how to use the BMY.
Two hundred and eighty cents, which requires an external driver for this to something to show you how
to find and install this driver before you can use.