1
00:00:02,100 --> 00:00:10,290
Ireland will come this new on in child going to edit our code and include the analogue sensor, now

2
00:00:10,290 --> 00:00:17,970
we've already mentioned that we will connect 11:35 sensor and according to our schematic, we need to

3
00:00:17,970 --> 00:00:21,960
check a pin that supports analog signal.

4
00:00:23,130 --> 00:00:26,790
Now, let's go back to the schematic before anything accord.

5
00:00:28,380 --> 00:00:33,210
Now, think you can see that we have connected alarm 35 in.

6
00:00:34,470 --> 00:00:37,770
To then, without the number 34.

7
00:00:39,210 --> 00:00:40,830
So we want.

8
00:00:42,050 --> 00:00:42,710
No, here.

9
00:00:44,350 --> 00:00:45,160
Dark clouds.

10
00:00:47,350 --> 00:00:53,620
Make sure the temperature sensor is assigned to 34, which is the pin number.

11
00:00:54,590 --> 00:01:02,840
Now, in order to, let's say, read analog signal, we need to go and create a new variable here.

12
00:01:04,099 --> 00:01:05,390
Let's call it into, Josh.

13
00:01:10,410 --> 00:01:10,740
And.

14
00:01:12,470 --> 00:01:20,390
Value, which means that which are of value, and that's Mankins, you know, sort saw the unlock value

15
00:01:20,390 --> 00:01:22,940
inside here from our temperature sensor.

16
00:01:24,020 --> 00:01:26,990
Now we won't do anything inside the vault set up.

17
00:01:28,160 --> 00:01:31,610
We need to go to the loop function here.

18
00:01:32,890 --> 00:01:40,240
Now we can send the, let's say, temperature value if motion is affected, so each time a motion is

19
00:01:40,240 --> 00:01:47,680
defeated, we will send a message indicating that the multichannel value all we can send it outside

20
00:01:48,580 --> 00:01:50,740
that temperature value with a delay.

21
00:01:52,870 --> 00:01:55,630
So let's send it outside.

22
00:01:56,290 --> 00:02:04,000
First, we need to get the value so I can a value equal, and I agreed.

23
00:02:06,300 --> 00:02:13,590
Now, I don't agree that it's the function that feeds analogue input and we need to pass that pin value.

24
00:02:13,650 --> 00:02:21,990
So let's go back to make sure that we have the right term value in virtual sense or is the variable

25
00:02:21,990 --> 00:02:23,190
that has the pin value.

26
00:02:24,160 --> 00:02:25,300
Which is 34.

27
00:02:26,950 --> 00:02:29,740
Now, as you are done, you can't send Syria.

28
00:02:31,090 --> 00:02:32,770
But friends and.

29
00:02:34,930 --> 00:02:37,720
With centimeter or temperature value?

30
00:02:41,040 --> 00:02:43,200
And you can simply delay.

31
00:02:45,590 --> 00:02:47,330
This is five hundred milliseconds.

32
00:02:49,030 --> 00:02:57,400
Now, this code will simply read the temperature sensor value and prints those values and see the monitor.

33
00:02:59,010 --> 00:03:09,840
We assign pin number 34 to this purpose, and we use the analogy to read function, which basically

34
00:03:09,840 --> 00:03:16,110
takes the value and the storage inside the value variable.

35
00:03:17,220 --> 00:03:19,830
Now let's say a few things.

36
00:03:20,520 --> 00:03:30,720
The first thing that you need to do or to know is that SB 32 has 15 analog digital converter pens that

37
00:03:30,720 --> 00:03:32,670
you can use to read analog inputs.

38
00:03:33,630 --> 00:03:36,860
These pens have a resolution of 12 bit.

39
00:03:37,650 --> 00:03:43,410
And when I said, as a union, we mean that you will get the values and this value variable between

40
00:03:43,410 --> 00:03:43,860
zero.

41
00:03:46,410 --> 00:03:47,900
You know, on four thousand.

42
00:03:49,580 --> 00:03:49,910
Ninety.

43
00:03:51,230 --> 00:03:57,080
Three, the value inside in the EU can simply use the agreed function.

44
00:03:58,100 --> 00:04:03,740
They S.B. 32 pens or ADC pens don't have a linear behavior.

45
00:04:04,160 --> 00:04:13,940
You will probably won't be able to distinguish between zero and 0.1 volt, all between 3.2 and 3.3 volt.

46
00:04:14,480 --> 00:04:18,560
The need to keep that in mind when using these ADC pens.

47
00:04:19,839 --> 00:04:24,400
Now, this means that we are leaving the value and printing it on the monitor.

48
00:04:25,000 --> 00:04:33,790
If you want to send it to your Telegram bot, you need to make sure that you use the send message feature.

49
00:04:34,630 --> 00:04:43,330
The send message will send anything to your Telegram bot so you can easily copy this line.

50
00:04:45,400 --> 00:04:46,750
And based its here.

51
00:04:48,730 --> 00:04:53,410
Now, sort of sending the motion has been detected sentence.

52
00:04:55,510 --> 00:05:01,180
Now, one thing that you need to know is that we cannot simply send the temperature, value and asset

53
00:05:01,180 --> 00:05:07,630
of our message because this is this thing and this is a variable so you can visit here, but you will

54
00:05:07,630 --> 00:05:10,020
get a compiling or compilation error.

55
00:05:11,290 --> 00:05:14,190
So you need to convert this to think, hmm.

56
00:05:15,680 --> 00:05:17,090
Go ahead, Android Sling.

57
00:05:19,290 --> 00:05:21,300
Let's name it, Cinsault.

58
00:05:23,770 --> 00:05:27,040
Message and use the string function.

59
00:05:28,510 --> 00:05:38,320
The same function will take the temperature value as input, which is about integer variable, and we

60
00:05:38,410 --> 00:05:41,500
want converted to decimal string.

61
00:05:42,310 --> 00:05:44,140
Now we can send the central message.

62
00:05:46,010 --> 00:05:52,100
He is inside our message board that a massage function.

63
00:05:53,030 --> 00:06:00,560
So this will take our chat I.D. since our message, which is this thing or our temperature value and

64
00:06:00,560 --> 00:06:01,190
this text.

65
00:06:01,460 --> 00:06:03,380
Some people prefer to do it like that.

66
00:06:04,130 --> 00:06:05,570
They send the temperature.

67
00:06:08,590 --> 00:06:11,470
Value loss, double string.

68
00:06:12,770 --> 00:06:14,450
So you can use this.

69
00:06:16,620 --> 00:06:18,610
Or you can simply send this.

70
00:06:22,120 --> 00:06:23,440
Now we'll try both of them.

71
00:06:24,190 --> 00:06:25,930
But let's first go with the first one.

72
00:06:27,340 --> 00:06:28,960
Now, let's verify the code.

73
00:06:42,680 --> 00:06:43,520
None combining.

74
00:06:43,550 --> 00:06:44,360
As you can see here.

75
00:06:45,630 --> 00:06:47,430
Now, let's test this out.

76
00:06:48,660 --> 00:06:52,110
Let's connect our ISP bond to our computer.

77
00:06:54,040 --> 00:07:00,700
Now we have our board connected, so go to tools, make sure that the right balls selected comfort and

78
00:07:00,700 --> 00:07:01,810
hit the upload button.

79
00:07:05,190 --> 00:07:11,760
Now open the year monitor just to make sure that once the code is uploaded, we can get the readings

80
00:07:11,760 --> 00:07:12,600
directly here.

81
00:07:15,710 --> 00:07:26,000
We also need to turn on our let's say, Android simulator, I use Bluestar to test things out because

82
00:07:26,000 --> 00:07:26,960
I have an iPhone.

83
00:07:28,260 --> 00:07:28,920
And.

84
00:07:30,080 --> 00:07:31,340
I have it configured.

85
00:07:32,340 --> 00:07:33,780
Or a different number?

86
00:07:35,170 --> 00:07:39,550
So as you can see here, it's trying to connect to I find we have the code of.

87
00:07:41,440 --> 00:07:48,130
And as long as you see dots, it means that anything to our final world is.

88
00:07:49,620 --> 00:07:57,780
On the way now, if you faced problem anything quite far from the first time you come, visit the board.

89
00:08:02,750 --> 00:08:03,320
And.

90
00:08:04,300 --> 00:08:05,890
Let's open the Telegram app.

91
00:08:08,140 --> 00:08:10,600
While trying to connect, all I find it's worth.

92
00:08:27,980 --> 00:08:33,890
OK, now as you can see, why is connected and enhanced, we are getting the analog value.

93
00:08:34,580 --> 00:08:39,890
And before going to Telegram what we need to make sure that the temperature sensor is working, and

94
00:08:39,890 --> 00:08:47,300
we already mentioned that this is a 12 bit resolution, do something better off going to the calculator.

95
00:08:48,530 --> 00:08:57,440
You can easily see that using a 12:08 means that we have values between zero and two to the power of

96
00:08:58,070 --> 00:08:58,490
less.

97
00:08:59,790 --> 00:09:01,320
Bring the scientific calculator.

98
00:09:02,320 --> 00:09:03,910
Two to the power of.

99
00:09:05,170 --> 00:09:12,410
He is to all of 12, so we'll have values between zero and four thousand ninety six.

100
00:09:12,620 --> 00:09:15,110
So let's try changing the temperature.

101
00:09:17,610 --> 00:09:18,690
All the way down.

102
00:09:19,690 --> 00:09:21,670
Now we are getting zero value.

103
00:09:21,790 --> 00:09:23,770
Let's change it all the way up.

104
00:09:26,170 --> 00:09:30,190
Now, as you can see, we are getting four thousand ninety five.

105
00:09:30,640 --> 00:09:37,720
Now we've got 95, not 96, because as you can see, it's starting from zero, if it's starting from

106
00:09:37,720 --> 00:09:38,050
one.

107
00:09:38,110 --> 00:09:40,120
It will get four thousand ninety six.

108
00:09:41,320 --> 00:09:44,620
Now let's go to our Telegram bots and.

109
00:09:45,880 --> 00:09:46,720
See the about.

110
00:09:47,140 --> 00:09:51,040
And here you can see that we are getting values.

111
00:09:51,700 --> 00:09:54,580
This is the emotional anthem which are what started up.

112
00:09:55,330 --> 00:09:58,780
And here are getting the temperature values that we have sent.

113
00:09:59,230 --> 00:10:01,900
Now I will change it and make it like in the middle.

114
00:10:04,290 --> 00:10:09,060
You will see results are changing now around 2700.

115
00:10:12,100 --> 00:10:20,950
Now, another trick that we can do inside our code is to change the value before sending it now, since

116
00:10:20,950 --> 00:10:22,690
we are sending a temperature value.

117
00:10:23,140 --> 00:10:25,750
We will be sending values in cities, yes.

118
00:10:26,470 --> 00:10:28,810
So the first thing that we need to do is.

119
00:10:29,970 --> 00:10:31,260
Final film.

120
00:10:33,410 --> 00:10:36,800
Divide the value for the temperature value by.

121
00:10:38,770 --> 00:10:39,760
4000.

122
00:10:41,090 --> 00:10:42,890
Ninety five.

123
00:10:43,910 --> 00:10:46,940
Now this one gives us a value.

124
00:10:50,610 --> 00:10:55,680
Now, to write out the question, you need to know that the temperature according to that sheet.

125
00:10:57,330 --> 00:10:58,080
Temperature.

126
00:10:59,300 --> 00:11:02,000
And solicitous equals the V out.

127
00:11:03,230 --> 00:11:07,760
Divided by 10 now, the view out must be an evolved.

128
00:11:10,570 --> 00:11:15,010
As you can see in here now, we need to make this equation to match this.

129
00:11:18,140 --> 00:11:25,370
And to make this happen first, we need to make sure that we are getting values and relevant now since

130
00:11:25,370 --> 00:11:28,400
we are measuring 3.3 Vault.

131
00:11:28,640 --> 00:11:32,990
We are using a 3.3 evolved from zero to 3.3 vault level.

132
00:11:33,740 --> 00:11:36,530
We need to convert the 3.3 vault to my evolved.

133
00:11:37,220 --> 00:11:38,840
And the easiest way to do this.

134
00:11:40,820 --> 00:11:46,880
Is to multiply it by 1000, as you can see here, we have 3300.

135
00:11:47,570 --> 00:11:50,960
So the first thing is getting the value.

136
00:11:52,120 --> 00:11:57,670
Commercial value from our sensor and multiplied by 3000 the hundreds.

137
00:11:58,770 --> 00:12:07,050
Now, after doing that, we need to divine this value by the maximum value of our digital reading,

138
00:12:07,440 --> 00:12:12,360
since we have 12 bit resolution, we need to divide it by 4000.

139
00:12:13,770 --> 00:12:14,540
Ninety six.

140
00:12:15,620 --> 00:12:17,420
Let's make sure that we have the right number.

141
00:12:19,260 --> 00:12:21,660
As you can see, four thousand ninety six.

142
00:12:24,120 --> 00:12:26,010
Now closed, that policy is.

143
00:12:27,650 --> 00:12:29,240
Now, if we apply this equation.

144
00:12:31,450 --> 00:12:34,750
We will get the reading and voltage.

145
00:12:35,470 --> 00:12:36,190
This will be.

146
00:12:38,440 --> 00:12:39,010
Vault.

147
00:12:40,070 --> 00:12:40,760
Temperature.

148
00:12:42,930 --> 00:12:53,790
And to give the actual temperature, we can go and write and actual, and it will equal the ball temperature

149
00:12:53,820 --> 00:13:00,420
that we took from this equation divided by then, as we mentioned in this equation.

150
00:13:02,730 --> 00:13:12,660
So we did this to convert three things from a value between zero and four thousand ninety six to Millarworld

151
00:13:12,870 --> 00:13:15,540
range, and we got the value here.

152
00:13:16,200 --> 00:13:20,910
Then we divide the value by 10 to get the actual temperature Inslee's use.

153
00:13:22,770 --> 00:13:30,620
And now the final step is sending the actual temperature and these to our string.

154
00:13:31,320 --> 00:13:33,000
So give this hobby.

155
00:13:34,060 --> 00:13:36,880
That value and based, it's here.

156
00:13:38,650 --> 00:13:43,430
Now, let's this this hour to see if it works or not, we might need to change a few variables below

157
00:13:43,430 --> 00:13:44,110
our equation.

158
00:13:45,240 --> 00:13:46,650
So let's applaud the cold.

159
00:13:50,950 --> 00:13:57,000
And wait to see hear if we will get values for temperature, and she leaves us.

160
00:14:13,520 --> 00:14:20,390
Now we can monitor the sea level going to the beginning, and we will give the same values on our telegram,

161
00:14:20,390 --> 00:14:20,720
what?

162
00:14:27,100 --> 00:14:30,800
Now is trying to connect, though, I find it work, so let's sort of said this.

163
00:14:44,010 --> 00:14:44,400
OK.

164
00:14:44,470 --> 00:14:45,750
My wife is connected.

165
00:14:46,290 --> 00:14:49,800
And as you can see, motion and temperature up.

166
00:14:51,500 --> 00:14:59,750
Now here we are getting these values, 2400, which are the actual reading from our ABC.

167
00:15:00,500 --> 00:15:02,090
And here we are, getting zeros.

168
00:15:02,300 --> 00:15:05,480
So I need to check why we are getting the zeros.

169
00:15:08,200 --> 00:15:11,110
Let's bring the value to zero.

170
00:15:19,340 --> 00:15:22,550
Now, let's go back to check what's happening.

171
00:15:26,540 --> 00:15:31,280
OK, now, since we are getting zeros, this is because here we have a division.

172
00:15:32,060 --> 00:15:39,080
And once you divide that, score the calculator, once you divide three thousand three hundred by four

173
00:15:39,080 --> 00:15:47,540
thousand ninety six, you will get a zero as the integer or the result you will get you will not get

174
00:15:47,540 --> 00:15:48,360
any reminders.

175
00:15:48,380 --> 00:15:49,760
Here we are using integer.

176
00:15:50,450 --> 00:15:52,460
So let's do a few modifications.

177
00:15:53,180 --> 00:15:55,930
Change this to float sorting.

178
00:15:57,590 --> 00:16:08,600
Now in here at point zero point zero, this will help our division bosses indicated that we want floats

179
00:16:08,600 --> 00:16:09,020
as well.

180
00:16:09,920 --> 00:16:12,170
Here we can cast this to float.

181
00:16:16,010 --> 00:16:17,390
Was this an integer value?

182
00:16:17,600 --> 00:16:19,880
And here we can add 10, one zero.

183
00:16:20,630 --> 00:16:25,910
Now I added fuel trend line to see the results from each of these steps.

184
00:16:27,640 --> 00:16:29,590
Now, let's upload the codes.

185
00:16:52,310 --> 00:16:55,220
OK, now, as you can see, that's trying to connect.

186
00:17:10,069 --> 00:17:11,569
Now getting the right results.

187
00:17:11,990 --> 00:17:14,780
This is the first results from the laser converter.

188
00:17:15,619 --> 00:17:19,310
And as you can see here are getting the numbers.

189
00:17:19,670 --> 00:17:27,619
This one is the world temperature and medivolve, and the second number is the actual temperature and

190
00:17:27,619 --> 00:17:28,150
sleaziest.

191
00:17:28,430 --> 00:17:32,600
This is the value that we are sending, so we should get 42.

192
00:17:33,850 --> 00:17:37,090
And our it go up.

193
00:17:37,420 --> 00:17:38,380
So let's go here.

194
00:17:39,100 --> 00:17:41,770
And as you can see, we are getting the temperature.

195
00:17:42,930 --> 00:17:49,410
Now you can increase it or decrease it by heating up or down temperature sensor.

196
00:17:51,440 --> 00:17:54,980
As you can see, it went to zero.

197
00:17:55,670 --> 00:17:56,600
Now from there.

198
00:17:57,680 --> 00:18:00,350
You can increase it a little bit.

199
00:18:03,840 --> 00:18:07,890
And he says, well, getting 17 cities, yes.

200
00:18:08,620 --> 00:18:15,140
And this is how to do read and unlock value using SB 32 and sentimental values to your Telegram bot.

201
00:18:15,930 --> 00:18:18,180
So what we learned so far is how.

202
00:18:19,240 --> 00:18:25,810
To detect motion and get that message when there is motion and how to get temperature value now to make

203
00:18:25,810 --> 00:18:27,880
things even more convenient.

204
00:18:28,810 --> 00:18:33,130
Let's go to our codes and take this value a little value.

205
00:18:33,820 --> 00:18:38,980
Now, once we take the temperature reading, we need to go down here.

206
00:18:41,400 --> 00:18:48,630
Or we can take the actual conclusion, sleaziest, and we will only send a message if the temperatures

207
00:18:48,630 --> 00:18:51,400
above, let's say, thirsty for air.

208
00:18:55,630 --> 00:19:03,100
Temperature or actual temperature, sleaziest is above all, equal 30 then and this cold.

209
00:19:05,760 --> 00:19:15,270
Otherwise done and now will only get messages if the temperature is about 50, not only to make our

210
00:19:15,270 --> 00:19:21,420
message look more convenient, they will send the line indicating that this is the temperature.

211
00:19:26,000 --> 00:19:30,260
Now, let's applaud the code to see the impact of this action.

212
00:19:44,070 --> 00:19:47,790
Now, it will take a few seconds to applaud the court order board.

213
00:19:50,470 --> 00:19:57,070
Let's see both of the trek from Seattle monitor side by side.

214
00:19:59,370 --> 00:19:59,730
OK.

215
00:19:59,760 --> 00:20:00,720
Trying to connect.

216
00:20:03,500 --> 00:20:04,820
Now, let's reset the board.

217
00:20:33,040 --> 00:20:38,380
Now, as you can see, we are getting values very fast in the film because we haven't other the delay

218
00:20:39,040 --> 00:20:40,390
in the void law.

219
00:20:41,230 --> 00:20:44,080
But now we have some ritual at zero.

220
00:20:44,230 --> 00:20:45,280
Let's increase it.

221
00:20:46,950 --> 00:20:48,180
A little bit above.

222
00:20:50,510 --> 00:20:52,640
The threshold that we have placed.

223
00:20:54,170 --> 00:20:59,300
Now it's around 31, so we are getting temperature 31.

224
00:21:00,610 --> 00:21:04,090
As you can see in the Telegram bot, we are getting values.

225
00:21:05,900 --> 00:21:08,720
Now again.

226
00:21:10,010 --> 00:21:14,630
We scrolled back to zero of our value that's below 30.

227
00:21:14,810 --> 00:21:18,710
You will not get any messages onto your Telegram bot.

228
00:21:19,220 --> 00:21:25,070
And this is basically how easy it is to set a condition so you only get Telegram messages.

229
00:21:26,020 --> 00:21:35,110
If this condition is true, so if actual conditions above 30, this is a condition that, let's say

230
00:21:35,110 --> 00:21:41,830
our ESB must warn us about, so it will send us a message that in August that temperature and something

231
00:21:41,830 --> 00:21:42,910
else the temperature value.

232
00:21:44,080 --> 00:21:45,960
Otherwise, we will not get a message.

233
00:21:46,000 --> 00:21:47,530
So that's it.

234
00:21:47,980 --> 00:21:58,210
You learned how to read digital sense of value and sent ID to your Telegram bots using SB 32.

235
00:21:58,480 --> 00:22:05,290
You also learned how to read the looks and values and send notifications on a specific condition like

236
00:22:05,440 --> 00:22:06,520
ice and temperature.

237
00:22:07,420 --> 00:22:11,200
And you will get notified on your Telegram bot as well.

238
00:22:12,120 --> 00:22:13,240
Thanks for watching this lesson.

239
00:22:13,260 --> 00:22:15,210
If you have any questions, I mean, to help.

240
00:22:15,720 --> 00:22:18,900
This is Ashraf from educational engineering team.

