1
00:00:00,730 --> 00:00:02,320
Hello, and welcome to this new lesson.

2
00:00:02,590 --> 00:00:05,950
Now let's start by calling the first method.

3
00:00:06,490 --> 00:00:17,530
First, we need to read the incoming data so light humidity, flawed humidity equals, which is the

4
00:00:17,620 --> 00:00:19,870
object that we all have defined speed.

5
00:00:20,710 --> 00:00:21,430
Humidity.

6
00:00:24,200 --> 00:00:28,190
The next one is for float, for the temperature.

7
00:00:30,520 --> 00:00:32,980
By DHT Dot read.

8
00:00:34,900 --> 00:00:41,770
Then, Richard, now we have the humidity and temperature to send them.

9
00:00:42,970 --> 00:00:52,060
We can easily use the Vishwa write function that is going to Blink Library has a method called Vishwa

10
00:00:52,060 --> 00:00:56,890
Right, which is used to write vessels for reading into virtual pens.

11
00:00:56,890 --> 00:01:02,560
We have or we will define and configure and our playing up.

12
00:01:02,770 --> 00:01:09,730
So to do this, simply write Blink Dot Virtual.

13
00:01:11,800 --> 00:01:12,310
Right.

14
00:01:13,780 --> 00:01:18,760
Now, first, define the virtual pin.

15
00:01:19,810 --> 00:01:21,550
Let's call it V.

16
00:01:24,970 --> 00:01:27,820
Five, and we will send humidity.

17
00:01:32,620 --> 00:01:35,650
And we will do the same for the temperature.

18
00:01:41,010 --> 00:01:43,260
Let's call it the fourth.

19
00:01:44,260 --> 00:01:50,440
And let's and the temperature in its.

20
00:01:52,220 --> 00:01:59,510
That's it now, this is the first function now, the second function, what we will do in the second

21
00:01:59,510 --> 00:02:01,970
function is basically the same thing.

22
00:02:02,510 --> 00:02:04,070
We will be the water level.

23
00:02:05,270 --> 00:02:08,870
And we already defined two variables here and here.

24
00:02:11,080 --> 00:02:17,320
So the water level will equal analog read function.

25
00:02:19,630 --> 00:02:23,770
And this will equal analog.

26
00:02:24,900 --> 00:02:36,090
Reads Now we need to bring the two variables here at water level since our pin number and the salts

27
00:02:36,090 --> 00:02:37,200
and salt pin number.

28
00:02:40,920 --> 00:02:46,260
Now we have two analog readings and two map them, we can easily use this function.

29
00:02:46,770 --> 00:02:48,150
You cut out water level.

30
00:02:50,480 --> 00:03:04,040
Equal mob and inside the mob, you can add water level and the rains zero two thousand zero.

31
00:03:05,260 --> 00:03:10,420
Twenty five, now the same thing can be done for the.

32
00:03:11,570 --> 00:03:19,940
Moisture level will equal mob and will do the very same thing.

33
00:03:20,840 --> 00:03:32,300
We were right, most certainly will, and we would add zero 4000 the zero to five or let's make it 20

34
00:03:32,930 --> 00:03:34,340
hundreds make this one 20.

35
00:03:34,580 --> 00:03:35,430
Now this.

36
00:03:35,450 --> 00:03:41,000
These values are depending on my sense of readings and the range that I want to get.

37
00:03:41,420 --> 00:03:47,000
Now, depending on your type of sense of your data sheet, you need to make sure that you are choosing

38
00:03:47,000 --> 00:03:49,410
the right values.

39
00:03:49,910 --> 00:03:50,870
Now to know.

40
00:03:52,650 --> 00:03:54,960
The arguing malfunction.

41
00:03:56,870 --> 00:04:00,770
Let's take a quick look at its description now.

42
00:04:01,130 --> 00:04:10,310
The map is basically a way to put heat maps a number from one range to another that is a value from

43
00:04:11,930 --> 00:04:14,300
low would get map tool to law.

44
00:04:15,110 --> 00:04:15,620
Now.

45
00:04:17,880 --> 00:04:24,000
It does not constrain values to within the range, because out of range values are sometimes intended

46
00:04:24,000 --> 00:04:31,050
and useful, that constrains function may be used either before or after this function if limits to

47
00:04:31,050 --> 00:04:35,110
that energies are desired, depending on your end goal.

48
00:04:35,130 --> 00:04:38,700
You can either use the constraints function or don't use it.

49
00:04:39,300 --> 00:04:47,970
Now you can see here, the map will take a value and from law from high to low and to high, so it will

50
00:04:47,970 --> 00:04:54,600
turn the value from low total as you can see this to this.

51
00:04:55,440 --> 00:05:03,990
And from high to high, as you can see from this to this now, the value is done on bottom up from low.

52
00:05:04,050 --> 00:05:11,370
The lower bound of the values can range from high, the upper bound of the values current range to low,

53
00:05:11,910 --> 00:05:14,960
the lower bound of the values target range.

54
00:05:14,970 --> 00:05:19,680
The one that we want to high the upper bound of the values target range.

55
00:05:20,250 --> 00:05:22,710
Now, as you can see, this is an example code.

56
00:05:23,190 --> 00:05:29,430
We are mapping an analog value to eight bits zero to 255.

57
00:05:30,750 --> 00:05:33,000
As you can see, here we are reading the value.

58
00:05:33,210 --> 00:05:43,770
And here we are, getting the readings from zero to 1023 and we want them to be up to zero to 255.

59
00:05:44,340 --> 00:05:54,010
So one thousand twenty three will provide an output of 255 and will be stored.

60
00:05:54,070 --> 00:05:54,990
The value here.

61
00:05:55,590 --> 00:06:00,450
So it's basically a way to change from this range to this range.

62
00:06:01,320 --> 00:06:09,330
As you can see, and we are using the very same methodology here we are moving the values from this

63
00:06:09,330 --> 00:06:13,050
range from zero to 2000 to this range from zero to 20.

64
00:06:13,710 --> 00:06:16,740
And here we are, moving the values from zero to 4000.

65
00:06:17,100 --> 00:06:19,320
So this range from zero to 20.

66
00:06:19,890 --> 00:06:30,570
So very easy, straightforward and easy to implement, way to change the range from a very large range

67
00:06:30,570 --> 00:06:31,890
to a very small one.

68
00:06:32,370 --> 00:06:36,510
And they will both provide the very same final result.

69
00:06:37,690 --> 00:06:45,280
Now, this is regarding the mapping, and since we now have the water level and moisture level, we

70
00:06:45,280 --> 00:06:50,080
can easily send the values using the blank dot virtual.

71
00:06:51,280 --> 00:06:55,300
Right function here we have seven.

72
00:06:57,880 --> 00:06:59,290
Water level.

73
00:07:00,920 --> 00:07:02,150
And here we have.

74
00:07:08,520 --> 00:07:10,170
Let's say we six.

75
00:07:12,410 --> 00:07:14,320
To send the most shows.

76
00:07:20,050 --> 00:07:20,470
Hello.

77
00:07:22,700 --> 00:07:27,530
Now, let's verify the code to make sure that we don't have any spelling or.

78
00:07:28,990 --> 00:07:32,460
Promising, unassuming column for moving forward.

79
00:07:36,110 --> 00:07:39,200
OK, now, as you can see here, we have A..

80
00:07:40,550 --> 00:07:43,100
We have a similar problem here.

81
00:07:53,180 --> 00:08:00,650
Hey, here we have I'm a bit cynical because I'm coding and see Python and Java.

82
00:08:02,250 --> 00:08:03,270
Sometimes.

83
00:08:04,400 --> 00:08:09,470
Such mistakes happens because, as you know, Python doesn't have a single column at the end of each

84
00:08:09,470 --> 00:08:10,070
sentence.

85
00:08:10,970 --> 00:08:11,330
OK.

86
00:08:14,350 --> 00:08:23,410
Now, Dan, combining everything is right now we can add an extra step here in this area and this extra

87
00:08:23,410 --> 00:08:29,230
three step will make sure that we are getting readings from the D.H sensor.

88
00:08:29,800 --> 00:08:35,140
But if you have connected it correctly, you won't need this step.

89
00:08:35,560 --> 00:08:37,600
You can add an if statement.

90
00:08:38,110 --> 00:08:43,510
If you are getting readings from that humidity and temperature, then move on.

91
00:08:43,600 --> 00:08:50,560
If not, then print a serial line, fail to read data from the sensor and you can do the same here.

92
00:08:51,370 --> 00:08:53,740
But I don't think that we need them now.

93
00:08:53,740 --> 00:08:57,290
We need to make sure that we memorize these numbers.

94
00:08:57,310 --> 00:09:04,710
We will give back to them in the blink explanation lesson.

95
00:09:05,860 --> 00:09:08,170
Now we are done with this.

96
00:09:10,740 --> 00:09:12,810
Function and we are done with this function.

97
00:09:13,530 --> 00:09:19,170
The next step is it's configuring the set up and the loop functions.

98
00:09:19,530 --> 00:09:23,370
And this will be an easy thing to do.

99
00:09:24,120 --> 00:09:27,510
Then we'll take an overall look this code.

100
00:09:27,780 --> 00:09:33,270
But let's summarize, or let's make a quick overview of what we have done here.

101
00:09:33,480 --> 00:09:41,520
We have used DST object to bring in the humidity and temperature since our values, and we have sent

102
00:09:41,520 --> 00:09:47,900
them to the blink using B5 and V4, which are their virtual pens.

103
00:09:48,950 --> 00:09:49,290
Sorry.

104
00:09:49,680 --> 00:09:57,450
Now we have used analog to need to read the water level and moisture level since the value, and we

105
00:09:57,450 --> 00:10:05,610
have used the map function to map the range from zero to 2000 to Al-Watan range, which is zero to 20

106
00:10:06,090 --> 00:10:07,680
and in the most liberal sense.

107
00:10:07,680 --> 00:10:14,730
Or we have used the map function to map these values from zero to 4000 to zero to 20.

108
00:10:15,230 --> 00:10:24,930
And then we have some values using the virtual write function and the library, and we use six and v

109
00:10:24,930 --> 00:10:32,070
seven as virtual pens for the blink up and the next lesson we will set up.

110
00:10:33,220 --> 00:10:38,940
We will write the code inside the setup and the loop functions to finish this coding process.

111
00:10:39,390 --> 00:10:40,250
Thanks for watching.

112
00:10:40,260 --> 00:10:43,890
If you have any question, please ask in the Q&amp;A about.
