1
00:00:00,720 --> 00:00:06,510
Hi and welcome to a new section in this course, in this section, you learn how to use a variety of

2
00:00:06,570 --> 00:00:13,350
senses, typical senses that you are unlikely to want to connect to your especially to start starting

3
00:00:13,350 --> 00:00:20,010
this lecture with a look at the THC 22, since this is so not only is very popular, obviously you probably

4
00:00:20,010 --> 00:00:28,590
have one in your choice already, but also because the ability to moderate Python firmware already comes

5
00:00:28,740 --> 00:00:30,870
with a driver for this sensor.

6
00:00:30,870 --> 00:00:35,130
So there's nothing else that you would need to import or to install.

7
00:00:35,610 --> 00:00:41,150
And therefore it makes it a very good choice for it being our first sensor.

8
00:00:41,880 --> 00:00:47,510
So I have connected this sensor on my breadboard to remove it.

9
00:00:47,550 --> 00:00:48,690
We can take a closer look.

10
00:00:49,290 --> 00:00:54,450
So I've got my sensor looking at it from the front where the grill is.

11
00:00:54,900 --> 00:00:56,970
Number one is power.

12
00:00:57,120 --> 00:00:59,980
I've connected that to three point three volts power.

13
00:01:00,030 --> 00:01:03,900
To the other side you've got ground pin number.

14
00:01:04,350 --> 00:01:07,590
It goes to ground, of course, a pin number three.

15
00:01:07,620 --> 00:01:10,350
This one right here is not connected to anything.

16
00:01:10,350 --> 00:01:11,790
Just leave it floating.

17
00:01:12,120 --> 00:01:18,420
And then pin number to this pin is the pin that I have connected it by this jumper wire to chip here,

18
00:01:18,550 --> 00:01:21,450
four to one that I have connected it.

19
00:01:21,460 --> 00:01:22,830
Just knowledge that is.

20
00:01:24,450 --> 00:01:31,980
Not in 04, actually put in 18, so it's fixed it on the fly right there.

21
00:01:32,280 --> 00:01:40,760
OK, so I'm going to plug the sensor back on my breadboard and have a look at the sketch.

22
00:01:41,340 --> 00:01:45,230
Now, I've got some information on how to connect your sensor.

23
00:01:45,270 --> 00:01:49,370
He could use DHT 22 or DHT 11 for this experiment.

24
00:01:49,380 --> 00:01:56,390
Either one will work and the driver for either one is available in the market, both in firmware.

25
00:01:56,820 --> 00:01:59,550
I've got information about this right here.

26
00:01:59,600 --> 00:02:01,980
Might start with this.

27
00:02:02,670 --> 00:02:03,630
So go to this.

28
00:02:03,630 --> 00:02:04,260
You're real.

29
00:02:04,410 --> 00:02:07,680
And we'll take you to the micro python documentation.

30
00:02:08,160 --> 00:02:11,250
And I'm looking at the E.S.P three two quick reference.

31
00:02:11,250 --> 00:02:13,710
And down here you'll see the DHT driver.

32
00:02:14,160 --> 00:02:19,110
You can choose between the 11 or the two.

33
00:02:19,620 --> 00:02:25,710
Just tell it which pin your data pin is connected to, which Appio, you terrapin of the sensor it's

34
00:02:25,710 --> 00:02:31,350
connected to, and then you can take a measurement by calling the measure function and then you can

35
00:02:31,350 --> 00:02:38,260
read out temperature and humidity by calling the appropriately named functions very easy.

36
00:02:38,640 --> 00:02:48,510
So in my sketch, this looks like that I have imported the module, importing the PIN and Taimur functions

37
00:02:48,510 --> 00:02:49,900
from the machine module.

38
00:02:50,520 --> 00:02:53,790
This is where I create my DHT 22 object.

39
00:02:54,150 --> 00:02:59,360
And then as you've learned in previous lectures, I'm using a timer.

40
00:02:59,610 --> 00:03:04,050
I've given it a period of 5000 milliseconds or five seconds.

41
00:03:04,260 --> 00:03:08,850
Is this since I was quite slow and it's a couple of seconds to recover.

42
00:03:09,330 --> 00:03:11,480
Each call takes a couple of seconds to complete.

43
00:03:11,730 --> 00:03:15,840
So five seconds seems like a reasonable amount of time to wait before the next measurement.

44
00:03:16,290 --> 00:03:24,360
And every time this clock ticks or every time this clock expires, I call the take measurement ISO function

45
00:03:24,360 --> 00:03:28,170
right here, which calls the measure function.

46
00:03:28,170 --> 00:03:33,160
And then I'm putting out temperature and humidity like this very easy.

47
00:03:34,050 --> 00:03:36,570
So let's try this out.

48
00:03:37,510 --> 00:03:45,340
Right now, I'm looking at this script as stored on my computer file system, so I am going to save

49
00:03:45,340 --> 00:03:45,940
a copy.

50
00:03:46,960 --> 00:03:56,120
And you can see that my security is connected, but it does not appear in the final steps.

51
00:03:56,150 --> 00:03:57,880
I'm just going to click on Stop.

52
00:03:59,120 --> 00:04:04,940
To wake it up and make this connection, that's why I got confused, I thought that it was a connected,

53
00:04:04,940 --> 00:04:13,430
but it was so here I am going to now save a copy to the Michael Python device.

54
00:04:13,970 --> 00:04:18,440
And I use the same name, DHT p y.

55
00:04:19,960 --> 00:04:21,730
Let's try this with lower case.

56
00:04:25,930 --> 00:04:26,290
OK.

57
00:04:28,360 --> 00:04:29,110
And.

58
00:04:30,350 --> 00:04:30,770
Play.

59
00:04:34,400 --> 00:04:35,530
Wait for five seconds.

60
00:04:36,960 --> 00:04:39,840
And there's a first measurement appears here.

61
00:04:42,090 --> 00:04:42,640
Right.

62
00:04:44,070 --> 00:04:46,050
Out of curiosity, let's see if the plot works.

63
00:04:56,580 --> 00:05:03,310
So the plot doesn't work because it can't figure out the values here that are coming out.

64
00:05:04,000 --> 00:05:12,510
I'm just going to turn this off and stop the execution and stop putting.

65
00:05:14,200 --> 00:05:16,150
And I'm just going to move.

66
00:05:18,610 --> 00:05:23,830
The values that save.

67
00:05:25,250 --> 00:05:26,380
And start again.

68
00:05:35,800 --> 00:05:41,210
Medicare now the employer can show the two values, GraphicLy.

69
00:05:45,150 --> 00:05:50,160
Of course, I'm just sending through the numbers instead of numbers, followed by the symbol of the

70
00:05:50,160 --> 00:05:54,940
value, I'm going to play around with a product as well in a later lecture.

71
00:05:54,960 --> 00:05:57,030
Well, we'll have a look at the accelerometer.

72
00:05:58,080 --> 00:05:59,040
All right, good.

73
00:05:59,070 --> 00:06:06,380
I'm going to put the symbols for the units back because that's how I'd like to keep my sketch.

74
00:06:06,420 --> 00:06:06,710
Right.

75
00:06:07,890 --> 00:06:13,950
So this was quite easy, as you can see, because the driver is part of the firmware.

76
00:06:14,370 --> 00:06:17,610
In the next lecture, I'll show you how to use the BMY.

77
00:06:17,610 --> 00:06:24,840
Two hundred and eighty cents, which requires an external driver for this to something to show you how

78
00:06:24,840 --> 00:06:28,020
to find and install this driver before you can use.
