Let's continue to extend the terrorism patrol vision, one slow to be able to receive input from the
consumer and then based on that input, decide whether to turn the pump on or off.
And I just remind you that in the Adreno slash is pithily to sketch, we are publishing information
or the value of the soil humidity sensor, the tumour to the soil humidity topic, which I've highlighted
here.
So I'm going to copy the topic because we need it immediately in our kitty in.
Noad.
So that this is the topic to which we'll subscribed to receive information about this, so your community
is confident going for a zero here of quality of service, and I'll call this note, get humidity.
So I should say soil humidity, good soil humidity.
All right.
Let's add a widget to the user interface.
Let's use the gauge.
And I'd like to place the widget in a new group called Soil Humidity.
So let's go in it and create a new group and they will go in the terrarium tab as well.
And I'll call that.
Soil humidity like this with six is fine.
All right, so there goes there, there's going to be a tide gauge.
For the label, let's give it the label of soil humidity for real value.
I'm OK with the value format and don't worry about the units.
The range is important.
It goes from zero to one thousand and twenty three since we have a 10 bit analog to digital converter
and can copy the soil humidity to the name of the node as well.
Let's deploy and see what we have going to go into the dashboard.
Here's the raw humidity and I should be able to just turn the knob of the particular mirror and you
can see that it is being updated.
Excellent.
I'm going to move the dashboard to the side so you can see what is happening on the Adreno or on the
E.S.P 32 and the values match.
I see.
If I move the consumer again, you can see that it's matching.
So you can stop this crawl here.
Notice that the value that was sent in, I know that because I've got the printout from the debugger
here is one fifty four, which is the value that was sent over to the to the flu.
But the most current value is one hundred and sixty one, which is not the same as what was sent and
received by no read.
But the difference between one fifty four and one sixty one is less than 10 and therefore the latest
one, which is 161, was not sent over to note read.
So that way in a way, throttle controlling how many updates the E.S.P 32 will be sending to no greater
think the value 10 is appropriate for this.
All right.
So now that we are getting so your humidity values from the ECB to we can actually use them to control
the pump, so.
To do this, we're going to use a function, so let's pick a function.
You connected.
To show your humility to the integrity in Noad.
To move things around a little, to make space, and then from here, I want to connect it directly
to the pump state, but I'm not going to do that yet because I want to rethink a little bit about how
many times I want to update my E.S.P 32 and change the state of the pump again, just like I'm throttling
the amount of messages or updates that are coming from the HP 32 to the node rate flow.
I also want to do a bit of throttling of updates from the flow itself to the E.S.P 30 to talk more about
it in a moment.
Let's go inside the functional and at a bit of JavaScript, but give it a name.
Call it pump operation.
Oops.
And then inside of JavaScript, I want a bit of code that will do a bit of testing of the value that
the flow has received from the consumer against the threshold.
So start with.
A pump state.
Viable in its initial values are going to be zero, so this is the value that the function will be sending
to its output, to the liquidity out pump, which is the same kind of values that we have manually entered
in the manual pump control widget, or I never got a statement.
So if the payload is arbitrarily, choose the value.
Five hundred.
So if the value stored in the payload coming from the soil committed to node is over five hundred,
then.
Make pump state.
One in this will turn on the pump or else the pump should be Xebra.
All right, and then for the return message, because it is connected to all this will be connected
to another node, I want to create a payload that would.
And the value of this payload will be pump state.
All right, so this should be OK to close in the moment of truth very soon to make sure it works.
All right.
To move these away, just make a bit of space now, as I was saying, I want to do thermal control so
that I don't update the expected to unnecessarily.
I only want to update the security when there is a change in the pump status that the pump operation
function is calculating.
So to do that, I'm going to use another widget.
Which is up here, it's CRB widget, and with the IBM widget, I am able to publish only changes of
whatever the operation note is sending.
So this is going to block unless the value is different, the new values different, the previous value
and it's going to forward the payload in that case.
So give it a name update.
The pump state changed, right.
And connect this output.
To the kitty out widget again to reposition the widgets like that.
Now that's one more thing that I also want to implement or change, actually, and I want the pump state
outputs both in the dashboard and the Dipak one to be connected to my igby node because that's now in
control of changes and that's in control of telling the utility what to do with the motor.
So I'm going to delete these two wires and reconnect them to the other node.
And of course, I want the pump control widget to directly control the state anymore.
I want this to also pass through the R, b, e note like that.
All right.
That appeared to make it look a little better.
So this should be good to go now and to test, so let's deploy and try it out.
I'm going to move the consumer to reach a value above five hundred and see if the motor starts.
So nothing happened with Emoto, which see what is happening here.
Nothing.
Let's see why not.
Five, five, six, nine, OK, so nothing happens with the Wynnum changing the value of the matter.
What about the gun control?
Does it work?
Pinkerton is working, so let's go back to Oslo and see why the pump control is not working.
So we know that the venues are updating correctly because we can see the state of the soil humidity
gauge changing that something is happening in here.
And of course, there is a typo.
So notice that there is a payload incorrectly spelled, so she'd be like that.
All right, let's try again to deploy and move the matter to above five hundred and that it's working.
Turn it off.
Perfect.
And the switch is also working, right?
So that's pretty good.
Let's move on to the next lecture.
We will do a recap of what we've done in this section and prepare for the next iteration of.