In the previous lecture, we implemented a new feature in the new Drechsler, which involves this threshold
setting budget, which allow us to manually set the threshold above which would like the pump to begin,
and that involved adding a bunch of nodes, including one that sends the set value for the threshold
to the ESB 32 via this topic right here.
So what we are going to do in this lecture is to make the necessary changes to the inability to sketch,
which is now version three.
This is a version that we are working on right now so that it can acquire this number from the topic
and use it internally to decide when to send an update to the market Kitty.
And therefore to the flow.
So I've already implemented the changes here and I'm going to walk you through them.
First of all, there's a new line here.
We've got a new variable that holds the soil humidity threshold, which, as you can see, points to
this topic, which is a topic that we are sending data from the floor.
We send in the value for the threshold from the slow next year, the on connection established function
of a new callback set for the threshold.
So when the get soil humidity threshold topic has an update, then this function will fire and set the
threshold to a local variable, which is.
This variable here, which I've said I've got a present here to four hundred like its default value,
so let's have a look at the callback function called set threshold.
So here it is, Threshold will receive a string, which is the value coming from the topic, then will
convert that string into an A. and story in the global community threshold.
And that's about it.
Now, the interesting thing happens right here in the report.
So your community function in the previous version of this scourge, we only had this condition for
the sketch to send an update or to publish the the new humidity from the sensor to the soil humidity
topic.
But now I'm also adding this condition.
So this an and I'm also sending this condition here.
So the reporting will take place also when the current humidity is larger than the soil humidity threshold,
regardless of the range.
So I thought this is important because this is going to allow us to to deal with said dry soil without
having to worry about how much change there is between measurements.
So as long as the current soil humidity as it was last measured is over the humidity threshold, then
we'll send this information to the flow so that it can decide whether we need to pump more water into
the soil.
So that's about it with the modification to the sketch to give us the version three of the terrorism
control.
So that's one more lecture in this section.
That's a next one where we'll do a quick test and demonstration of what we have so far to review and
then do a preview of what we're going to do in the next section.