Hello, and welcome to this new lesson.
Now let's start by calling the first method.
First, we need to read the incoming data so light humidity, flawed humidity equals, which is the
object that we all have defined speed.
Humidity.
The next one is for float, for the temperature.
By DHT Dot read.
Then, Richard, now we have the humidity and temperature to send them.
We can easily use the Vishwa write function that is going to Blink Library has a method called Vishwa
Right, which is used to write vessels for reading into virtual pens.
We have or we will define and configure and our playing up.
So to do this, simply write Blink Dot Virtual.
Right.
Now, first, define the virtual pin.
Let's call it V.
Five, and we will send humidity.
And we will do the same for the temperature.
Let's call it the fourth.
And let's and the temperature in its.
That's it now, this is the first function now, the second function, what we will do in the second
function is basically the same thing.
We will be the water level.
And we already defined two variables here and here.
So the water level will equal analog read function.
And this will equal analog.
Reads Now we need to bring the two variables here at water level since our pin number and the salts
and salt pin number.
Now we have two analog readings and two map them, we can easily use this function.
You cut out water level.
Equal mob and inside the mob, you can add water level and the rains zero two thousand zero.
Twenty five, now the same thing can be done for the.
Moisture level will equal mob and will do the very same thing.
We were right, most certainly will, and we would add zero 4000 the zero to five or let's make it 20
hundreds make this one 20.
Now this.
These values are depending on my sense of readings and the range that I want to get.
Now, depending on your type of sense of your data sheet, you need to make sure that you are choosing
the right values.
Now to know.
The arguing malfunction.
Let's take a quick look at its description now.
The map is basically a way to put heat maps a number from one range to another that is a value from
low would get map tool to law.
Now.
It does not constrain values to within the range, because out of range values are sometimes intended
and useful, that constrains function may be used either before or after this function if limits to
that energies are desired, depending on your end goal.
You can either use the constraints function or don't use it.
Now you can see here, the map will take a value and from law from high to low and to high, so it will
turn the value from low total as you can see this to this.
And from high to high, as you can see from this to this now, the value is done on bottom up from low.
The lower bound of the values can range from high, the upper bound of the values current range to low,
the lower bound of the values target range.
The one that we want to high the upper bound of the values target range.
Now, as you can see, this is an example code.
We are mapping an analog value to eight bits zero to 255.
As you can see, here we are reading the value.
And here we are, getting the readings from zero to 1023 and we want them to be up to zero to 255.
So one thousand twenty three will provide an output of 255 and will be stored.
The value here.
So it's basically a way to change from this range to this range.
As you can see, and we are using the very same methodology here we are moving the values from this
range from zero to 2000 to this range from zero to 20.
And here we are, moving the values from zero to 4000.
So this range from zero to 20.
So very easy, straightforward and easy to implement, way to change the range from a very large range
to a very small one.
And they will both provide the very same final result.
Now, this is regarding the mapping, and since we now have the water level and moisture level, we
can easily send the values using the blank dot virtual.
Right function here we have seven.
Water level.
And here we have.
Let's say we six.
To send the most shows.
Hello.
Now, let's verify the code to make sure that we don't have any spelling or.
Promising, unassuming column for moving forward.
OK, now, as you can see here, we have A..
We have a similar problem here.
Hey, here we have I'm a bit cynical because I'm coding and see Python and Java.
Sometimes.
Such mistakes happens because, as you know, Python doesn't have a single column at the end of each
sentence.
OK.
Now, Dan, combining everything is right now we can add an extra step here in this area and this extra
three step will make sure that we are getting readings from the D.H sensor.
But if you have connected it correctly, you won't need this step.
You can add an if statement.
If you are getting readings from that humidity and temperature, then move on.
If not, then print a serial line, fail to read data from the sensor and you can do the same here.
But I don't think that we need them now.
We need to make sure that we memorize these numbers.
We will give back to them in the blink explanation lesson.
Now we are done with this.
Function and we are done with this function.
The next step is it's configuring the set up and the loop functions.
And this will be an easy thing to do.
Then we'll take an overall look this code.
But let's summarize, or let's make a quick overview of what we have done here.
We have used DST object to bring in the humidity and temperature since our values, and we have sent
them to the blink using B5 and V4, which are their virtual pens.
Sorry.
Now we have used analog to need to read the water level and moisture level since the value, and we
have used the map function to map the range from zero to 2000 to Al-Watan range, which is zero to 20
and in the most liberal sense.
Or we have used the map function to map these values from zero to 4000 to zero to 20.
And then we have some values using the virtual write function and the library, and we use six and v
seven as virtual pens for the blink up and the next lesson we will set up.
We will write the code inside the setup and the loop functions to finish this coding process.
Thanks for watching.
If you have any question, please ask in the Q&A about.