Ireland will come this new on in child going to edit our code and include the analogue sensor, now
we've already mentioned that we will connect 11:35 sensor and according to our schematic, we need to
check a pin that supports analog signal.
Now, let's go back to the schematic before anything accord.
Now, think you can see that we have connected alarm 35 in.
To then, without the number 34.
So we want.
No, here.
Dark clouds.
Make sure the temperature sensor is assigned to 34, which is the pin number.
Now, in order to, let's say, read analog signal, we need to go and create a new variable here.
Let's call it into, Josh.
And.
Value, which means that which are of value, and that's Mankins, you know, sort saw the unlock value
inside here from our temperature sensor.
Now we won't do anything inside the vault set up.
We need to go to the loop function here.
Now we can send the, let's say, temperature value if motion is affected, so each time a motion is
defeated, we will send a message indicating that the multichannel value all we can send it outside
that temperature value with a delay.
So let's send it outside.
First, we need to get the value so I can a value equal, and I agreed.
Now, I don't agree that it's the function that feeds analogue input and we need to pass that pin value.
So let's go back to make sure that we have the right term value in virtual sense or is the variable
that has the pin value.
Which is 34.
Now, as you are done, you can't send Syria.
But friends and.
With centimeter or temperature value?
And you can simply delay.
This is five hundred milliseconds.
Now, this code will simply read the temperature sensor value and prints those values and see the monitor.
We assign pin number 34 to this purpose, and we use the analogy to read function, which basically
takes the value and the storage inside the value variable.
Now let's say a few things.
The first thing that you need to do or to know is that SB 32 has 15 analog digital converter pens that
you can use to read analog inputs.
These pens have a resolution of 12 bit.
And when I said, as a union, we mean that you will get the values and this value variable between
zero.
You know, on four thousand.
Ninety.
Three, the value inside in the EU can simply use the agreed function.
They S.B. 32 pens or ADC pens don't have a linear behavior.
You will probably won't be able to distinguish between zero and 0.1 volt, all between 3.2 and 3.3 volt.
The need to keep that in mind when using these ADC pens.
Now, this means that we are leaving the value and printing it on the monitor.
If you want to send it to your Telegram bot, you need to make sure that you use the send message feature.
The send message will send anything to your Telegram bot so you can easily copy this line.
And based its here.
Now, sort of sending the motion has been detected sentence.
Now, one thing that you need to know is that we cannot simply send the temperature, value and asset
of our message because this is this thing and this is a variable so you can visit here, but you will
get a compiling or compilation error.
So you need to convert this to think, hmm.
Go ahead, Android Sling.
Let's name it, Cinsault.
Message and use the string function.
The same function will take the temperature value as input, which is about integer variable, and we
want converted to decimal string.
Now we can send the central message.
He is inside our message board that a massage function.
So this will take our chat I.D. since our message, which is this thing or our temperature value and
this text.
Some people prefer to do it like that.
They send the temperature.
Value loss, double string.
So you can use this.
Or you can simply send this.
Now we'll try both of them.
But let's first go with the first one.
Now, let's verify the code.
None combining.
As you can see here.
Now, let's test this out.
Let's connect our ISP bond to our computer.
Now we have our board connected, so go to tools, make sure that the right balls selected comfort and
hit the upload button.
Now open the year monitor just to make sure that once the code is uploaded, we can get the readings
directly here.
We also need to turn on our let's say, Android simulator, I use Bluestar to test things out because
I have an iPhone.
And.
I have it configured.
Or a different number?
So as you can see here, it's trying to connect to I find we have the code of.
And as long as you see dots, it means that anything to our final world is.
On the way now, if you faced problem anything quite far from the first time you come, visit the board.
And.
Let's open the Telegram app.
While trying to connect, all I find it's worth.
OK, now as you can see, why is connected and enhanced, we are getting the analog value.
And before going to Telegram what we need to make sure that the temperature sensor is working, and
we already mentioned that this is a 12 bit resolution, do something better off going to the calculator.
You can easily see that using a 12:08 means that we have values between zero and two to the power of
less.
Bring the scientific calculator.
Two to the power of.
He is to all of 12, so we'll have values between zero and four thousand ninety six.
So let's try changing the temperature.
All the way down.
Now we are getting zero value.
Let's change it all the way up.
Now, as you can see, we are getting four thousand ninety five.
Now we've got 95, not 96, because as you can see, it's starting from zero, if it's starting from
one.
It will get four thousand ninety six.
Now let's go to our Telegram bots and.
See the about.
And here you can see that we are getting values.
This is the emotional anthem which are what started up.
And here are getting the temperature values that we have sent.
Now I will change it and make it like in the middle.
You will see results are changing now around 2700.
Now, another trick that we can do inside our code is to change the value before sending it now, since
we are sending a temperature value.
We will be sending values in cities, yes.
So the first thing that we need to do is.
Final film.
Divide the value for the temperature value by.
4000.
Ninety five.
Now this one gives us a value.
Now, to write out the question, you need to know that the temperature according to that sheet.
Temperature.
And solicitous equals the V out.
Divided by 10 now, the view out must be an evolved.
As you can see in here now, we need to make this equation to match this.
And to make this happen first, we need to make sure that we are getting values and relevant now since
we are measuring 3.3 Vault.
We are using a 3.3 evolved from zero to 3.3 vault level.
We need to convert the 3.3 vault to my evolved.
And the easiest way to do this.
Is to multiply it by 1000, as you can see here, we have 3300.
So the first thing is getting the value.
Commercial value from our sensor and multiplied by 3000 the hundreds.
Now, after doing that, we need to divine this value by the maximum value of our digital reading,
since we have 12 bit resolution, we need to divide it by 4000.
Ninety six.
Let's make sure that we have the right number.
As you can see, four thousand ninety six.
Now closed, that policy is.
Now, if we apply this equation.
We will get the reading and voltage.
This will be.
Vault.
Temperature.
And to give the actual temperature, we can go and write and actual, and it will equal the ball temperature
that we took from this equation divided by then, as we mentioned in this equation.
So we did this to convert three things from a value between zero and four thousand ninety six to Millarworld
range, and we got the value here.
Then we divide the value by 10 to get the actual temperature Inslee's use.
And now the final step is sending the actual temperature and these to our string.
So give this hobby.
That value and based, it's here.
Now, let's this this hour to see if it works or not, we might need to change a few variables below
our equation.
So let's applaud the cold.
And wait to see hear if we will get values for temperature, and she leaves us.
Now we can monitor the sea level going to the beginning, and we will give the same values on our telegram,
what?
Now is trying to connect, though, I find it work, so let's sort of said this.
OK.
My wife is connected.
And as you can see, motion and temperature up.
Now here we are getting these values, 2400, which are the actual reading from our ABC.
And here we are, getting zeros.
So I need to check why we are getting the zeros.
Let's bring the value to zero.
Now, let's go back to check what's happening.
OK, now, since we are getting zeros, this is because here we have a division.
And once you divide that, score the calculator, once you divide three thousand three hundred by four
thousand ninety six, you will get a zero as the integer or the result you will get you will not get
any reminders.
Here we are using integer.
So let's do a few modifications.
Change this to float sorting.
Now in here at point zero point zero, this will help our division bosses indicated that we want floats
as well.
Here we can cast this to float.
Was this an integer value?
And here we can add 10, one zero.
Now I added fuel trend line to see the results from each of these steps.
Now, let's upload the codes.
OK, now, as you can see, that's trying to connect.
Now getting the right results.
This is the first results from the laser converter.
And as you can see here are getting the numbers.
This one is the world temperature and medivolve, and the second number is the actual temperature and
sleaziest.
This is the value that we are sending, so we should get 42.
And our it go up.
So let's go here.
And as you can see, we are getting the temperature.
Now you can increase it or decrease it by heating up or down temperature sensor.
As you can see, it went to zero.
Now from there.
You can increase it a little bit.
And he says, well, getting 17 cities, yes.
And this is how to do read and unlock value using SB 32 and sentimental values to your Telegram bot.
So what we learned so far is how.
To detect motion and get that message when there is motion and how to get temperature value now to make
things even more convenient.
Let's go to our codes and take this value a little value.
Now, once we take the temperature reading, we need to go down here.
Or we can take the actual conclusion, sleaziest, and we will only send a message if the temperatures
above, let's say, thirsty for air.
Temperature or actual temperature, sleaziest is above all, equal 30 then and this cold.
Otherwise done and now will only get messages if the temperature is about 50, not only to make our
message look more convenient, they will send the line indicating that this is the temperature.
Now, let's applaud the code to see the impact of this action.
Now, it will take a few seconds to applaud the court order board.
Let's see both of the trek from Seattle monitor side by side.
OK.
Trying to connect.
Now, let's reset the board.
Now, as you can see, we are getting values very fast in the film because we haven't other the delay
in the void law.
But now we have some ritual at zero.
Let's increase it.
A little bit above.
The threshold that we have placed.
Now it's around 31, so we are getting temperature 31.
As you can see in the Telegram bot, we are getting values.
Now again.
We scrolled back to zero of our value that's below 30.
You will not get any messages onto your Telegram bot.
And this is basically how easy it is to set a condition so you only get Telegram messages.
If this condition is true, so if actual conditions above 30, this is a condition that, let's say
our ESB must warn us about, so it will send us a message that in August that temperature and something
else the temperature value.
Otherwise, we will not get a message.
So that's it.
You learned how to read digital sense of value and sent ID to your Telegram bots using SB 32.
You also learned how to read the looks and values and send notifications on a specific condition like
ice and temperature.
And you will get notified on your Telegram bot as well.
Thanks for watching this lesson.
If you have any questions, I mean, to help.
This is Ashraf from educational engineering team.