In the previous lecture, we implemented the first iteration of the sketch that is now running on the
E.S.P 32, and what we'll do now is to finish the first iteration of this project by creating the first
version of the terrorism controller note read flow.
There's a few ways you can go about creating this flow, but I think that the simplest way to get started
is to implement the component of the flow that controls the motor or the pump.
So imagine that we can access the dashboard here like a dashboard here.
I've got a group in which we've got a single widget like a a switch perhaps.
And when we click on the switch to turn on, then the motor turns on.
When we turn the switch off the motor potential so that we will know that we can control the state of
the motor from inside our terrarium control and node red flow.
And then we can move on to the next step, which is to implement the part of the flow that reads.
The value from the potential consumer takes a value and compares it to a threshold that we also set
and then turns on the motor or automatically without us having to use the manual switch.
So let's go ahead and implement this functionality in note read.
The first thing that I'll do is it take a switch and drop it onto my head and control of the wine flow
that I've just created a bit earlier and go in to change its settings.
So for the group in which this widget belongs, I will set it to the terrorism manual Pump Control.
It's a group that are created earlier.
She can see it right here and just leave the size to automatic for now.
We can play around with the user interface later for the label.
Let's call this.
Manual pump.
Control copy the same value down in the name field as well.
Now the payload is important.
Remember that in our Arduino sketch for the pathetic two down here, we would do the control, the control
function.
We are expecting a string.
So whatever the payload is, it needs to be a string and got a single character in it.
If the character easier than the pump is turned off and if the character is one, then the pump is turned
on.
So with that, let's change the payload from a bully into a string and make that a one so that when
the switch is on, that's the character or the string with a single character that comes out.
And then when the switch is off, another string, which is going to be zero.
All right, done.
And want to make sure that this is actually committed because I did have some trouble with this earlier.
Seems to be a small bug here with this particular widget.
So you can see that the old value is still true, even though I changed it and the value is false.
I'm not sure why this is happening.
So I noticed that actually, if I put a couple of values here like that, instead of a single shot,
if I put a couple of characters in the string instead of a single string, this seems to work better.
So now you can see that the old value and the of value are correct.
We can just let it go the way that it is.
And the security sketch will only read the first.
Character from this array of characters, which is the one in the zero, which are correct, but if
you want to be consistent with the values that you insert in the payload, so you don't see this a bit
later and get confused, you can just remove the second character and it should stay on since we were
able to move away from the original to enforce values.
So let's try that out.
Yeah, we've got a one and to zero.
So again, this I think it's a small bug with the user interface of the particular widget or they know
that we are working on with at the moment.
So I was able to tweak it and get it to work the way that I wanted.
All right.
So we've got the pump for deploy this.
You see the manual pump control is now in the group.
So the next thing we need to do is to send the value from the payload of the switch to the appropriate
and quiddity topic.
So I'm going to add a new node here for an hour.
Then instead of picking it from the left side, the left toolbar, you can just right click anywhere.
I'm using the control key here because I've only got one button in the mouse that I'm working with and
just search for the node that you want.
So let's get it out and connect it and its properties.
And for the name, I will say publish.
Whump state, just to make it obvious what it is for the server and I'll go for the client that is on
my note, Red Raspberry Pi and for the topic itself gets copied from the sketch.
And it's this topic that we want to publish to copy that.
And pasted in here.
OK, for quality of service, let's say, to the Zero and Kundun and deploy.
All right, let's check it out now and see if it works.
I've already turned on my benchtop power supply and I've said it to five volts, gets it right here.
It's ten dollars of power is provided to the material on my fretboard.
So I should be able to just turn it on.
It's working and turn it off again, perfect, and I'm just going to also show you what is happening
here in the studio monitor so you can see the output from the sketch.
Just give a bit more space.
All right.
So I'm going to turn it on.
This is the debug information from the library itself, and you can see that the state just took the
order scroll.
The state that it's received is one this message here is coming from.
This the debugging messages that we have enabled in the setup method.
All right, let's turn it off.
And you can see that the message was received by the U.S. military to immediately object.
All right.
So now we know that we can control the pump from the dashboard.
And before I move on to the consumer, I'd like to add a couple of other notes here just to finish up
with the manual pump control component.
So one thing that I would like to add is a simple text output widget.
Like this, so that on the dashboard itself, we can see in text the state of the pump, so I'm going
to place this in the terrarium pump group.
So the pump group, I plan to have information about the status of the pump.
So put it there, leave it to automatic and just say something like pump is pump state is.
And that will give us a one or a zero like this.
As for the label and for the name of the note, I just say pump state, all right, deploy.
And now it looks like this can see one and zero is updated.
And as I usually do with all of my flows, I also want to have a debug.
Our put.
So that I don't have to switch to the dashboard to see what is going on.
So this is going to be a pump state.
That is simply going to give me whatever comes out of manual control on the debug tab right here, because
remember that Alice flew in the next lecture will be able to automatically determine the pump state.
So I would like to be able to see the pump state here in the back window without switching to the to
the dashboard.
OK, so this is enough for the time being.
We can control the pump from our dashboard.
There's a little bit more work to be done here in order to improve it.
But it doesn't make sense to do this now because we really need to implement the part of the flow that
works with the potential mirror or the soil humidity sensor, which will automatically determine the
appropriate pump state.
And that will also probably make another small change here in the pump control part of the flow.
So let's move on to the next lecture.
Where will implement the heart of the terrorism controller, no feat that involves the potential.