1
00:00:00,330 --> 00:00:06,840
In the previous lecture, we implemented the first iteration of the sketch that is now running on the

2
00:00:06,840 --> 00:00:14,970
E.S.P 32, and what we'll do now is to finish the first iteration of this project by creating the first

3
00:00:14,970 --> 00:00:17,980
version of the terrorism controller note read flow.

4
00:00:18,540 --> 00:00:24,030
There's a few ways you can go about creating this flow, but I think that the simplest way to get started

5
00:00:24,420 --> 00:00:29,460
is to implement the component of the flow that controls the motor or the pump.

6
00:00:30,090 --> 00:00:35,740
So imagine that we can access the dashboard here like a dashboard here.

7
00:00:35,740 --> 00:00:41,640
I've got a group in which we've got a single widget like a a switch perhaps.

8
00:00:41,640 --> 00:00:46,410
And when we click on the switch to turn on, then the motor turns on.

9
00:00:47,340 --> 00:00:54,960
When we turn the switch off the motor potential so that we will know that we can control the state of

10
00:00:54,960 --> 00:00:59,190
the motor from inside our terrarium control and node red flow.

11
00:00:59,520 --> 00:01:05,910
And then we can move on to the next step, which is to implement the part of the flow that reads.

12
00:01:05,910 --> 00:01:11,280
The value from the potential consumer takes a value and compares it to a threshold that we also set

13
00:01:11,610 --> 00:01:18,060
and then turns on the motor or automatically without us having to use the manual switch.

14
00:01:19,590 --> 00:01:24,750
So let's go ahead and implement this functionality in note read.

15
00:01:25,500 --> 00:01:32,250
The first thing that I'll do is it take a switch and drop it onto my head and control of the wine flow

16
00:01:32,250 --> 00:01:39,320
that I've just created a bit earlier and go in to change its settings.

17
00:01:39,330 --> 00:01:48,860
So for the group in which this widget belongs, I will set it to the terrorism manual Pump Control.

18
00:01:48,870 --> 00:01:50,550
It's a group that are created earlier.

19
00:01:50,880 --> 00:01:56,400
She can see it right here and just leave the size to automatic for now.

20
00:01:56,400 --> 00:02:01,340
We can play around with the user interface later for the label.

21
00:02:02,430 --> 00:02:03,510
Let's call this.

22
00:02:05,850 --> 00:02:08,060
Manual pump.

23
00:02:09,950 --> 00:02:15,120
Control copy the same value down in the name field as well.

24
00:02:16,130 --> 00:02:17,690
Now the payload is important.

25
00:02:17,750 --> 00:02:29,150
Remember that in our Arduino sketch for the pathetic two down here, we would do the control, the control

26
00:02:29,540 --> 00:02:30,160
function.

27
00:02:30,410 --> 00:02:32,330
We are expecting a string.

28
00:02:32,750 --> 00:02:37,790
So whatever the payload is, it needs to be a string and got a single character in it.

29
00:02:37,790 --> 00:02:43,220
If the character easier than the pump is turned off and if the character is one, then the pump is turned

30
00:02:43,520 --> 00:02:43,940
on.

31
00:02:44,450 --> 00:02:53,210
So with that, let's change the payload from a bully into a string and make that a one so that when

32
00:02:53,210 --> 00:02:59,350
the switch is on, that's the character or the string with a single character that comes out.

33
00:02:59,870 --> 00:03:04,800
And then when the switch is off, another string, which is going to be zero.

34
00:03:05,630 --> 00:03:07,160
All right, done.

35
00:03:07,850 --> 00:03:14,270
And want to make sure that this is actually committed because I did have some trouble with this earlier.

36
00:03:16,170 --> 00:03:19,130
Seems to be a small bug here with this particular widget.

37
00:03:19,130 --> 00:03:27,170
So you can see that the old value is still true, even though I changed it and the value is false.

38
00:03:27,800 --> 00:03:29,480
I'm not sure why this is happening.

39
00:03:30,050 --> 00:03:38,400
So I noticed that actually, if I put a couple of values here like that, instead of a single shot,

40
00:03:38,430 --> 00:03:43,860
if I put a couple of characters in the string instead of a single string, this seems to work better.

41
00:03:44,570 --> 00:03:49,790
So now you can see that the old value and the of value are correct.

42
00:03:50,270 --> 00:03:52,550
We can just let it go the way that it is.

43
00:03:52,550 --> 00:03:59,300
And the security sketch will only read the first.

44
00:04:00,320 --> 00:04:05,480
Character from this array of characters, which is the one in the zero, which are correct, but if

45
00:04:05,480 --> 00:04:12,050
you want to be consistent with the values that you insert in the payload, so you don't see this a bit

46
00:04:12,050 --> 00:04:19,190
later and get confused, you can just remove the second character and it should stay on since we were

47
00:04:19,190 --> 00:04:22,610
able to move away from the original to enforce values.

48
00:04:23,360 --> 00:04:24,830
So let's try that out.

49
00:04:25,220 --> 00:04:28,300
Yeah, we've got a one and to zero.

50
00:04:28,340 --> 00:04:35,540
So again, this I think it's a small bug with the user interface of the particular widget or they know

51
00:04:35,540 --> 00:04:37,670
that we are working on with at the moment.

52
00:04:38,480 --> 00:04:42,990
So I was able to tweak it and get it to work the way that I wanted.

53
00:04:43,760 --> 00:04:44,010
All right.

54
00:04:44,060 --> 00:04:46,580
So we've got the pump for deploy this.

55
00:04:46,580 --> 00:04:50,480
You see the manual pump control is now in the group.

56
00:04:50,810 --> 00:04:58,280
So the next thing we need to do is to send the value from the payload of the switch to the appropriate

57
00:04:58,280 --> 00:04:59,270
and quiddity topic.

58
00:04:59,840 --> 00:05:05,180
So I'm going to add a new node here for an hour.

59
00:05:05,220 --> 00:05:10,070
Then instead of picking it from the left side, the left toolbar, you can just right click anywhere.

60
00:05:10,970 --> 00:05:16,190
I'm using the control key here because I've only got one button in the mouse that I'm working with and

61
00:05:16,190 --> 00:05:18,880
just search for the node that you want.

62
00:05:19,160 --> 00:05:24,950
So let's get it out and connect it and its properties.

63
00:05:24,950 --> 00:05:29,870
And for the name, I will say publish.

64
00:05:31,390 --> 00:05:39,040
Whump state, just to make it obvious what it is for the server and I'll go for the client that is on

65
00:05:39,040 --> 00:05:47,410
my note, Red Raspberry Pi and for the topic itself gets copied from the sketch.

66
00:05:47,410 --> 00:05:51,310
And it's this topic that we want to publish to copy that.

67
00:05:53,260 --> 00:05:54,310
And pasted in here.

68
00:05:55,740 --> 00:06:01,050
OK, for quality of service, let's say, to the Zero and Kundun and deploy.

69
00:06:01,730 --> 00:06:04,920
All right, let's check it out now and see if it works.

70
00:06:05,220 --> 00:06:11,630
I've already turned on my benchtop power supply and I've said it to five volts, gets it right here.

71
00:06:11,940 --> 00:06:17,520
It's ten dollars of power is provided to the material on my fretboard.

72
00:06:17,940 --> 00:06:19,830
So I should be able to just turn it on.

73
00:06:23,460 --> 00:06:32,370
It's working and turn it off again, perfect, and I'm just going to also show you what is happening

74
00:06:32,370 --> 00:06:40,140
here in the studio monitor so you can see the output from the sketch.

75
00:06:40,140 --> 00:06:41,550
Just give a bit more space.

76
00:06:41,970 --> 00:06:42,510
All right.

77
00:06:42,870 --> 00:06:43,770
So I'm going to turn it on.

78
00:06:47,840 --> 00:06:54,650
This is the debug information from the library itself, and you can see that the state just took the

79
00:06:54,650 --> 00:06:55,250
order scroll.

80
00:06:55,850 --> 00:07:02,540
The state that it's received is one this message here is coming from.

81
00:07:07,500 --> 00:07:11,940
This the debugging messages that we have enabled in the setup method.

82
00:07:13,180 --> 00:07:14,750
All right, let's turn it off.

83
00:07:19,070 --> 00:07:27,590
And you can see that the message was received by the U.S. military to immediately object.

84
00:07:28,670 --> 00:07:29,000
All right.

85
00:07:29,000 --> 00:07:33,970
So now we know that we can control the pump from the dashboard.

86
00:07:33,980 --> 00:07:40,100
And before I move on to the consumer, I'd like to add a couple of other notes here just to finish up

87
00:07:40,100 --> 00:07:43,300
with the manual pump control component.

88
00:07:43,370 --> 00:07:48,830
So one thing that I would like to add is a simple text output widget.

89
00:07:50,830 --> 00:07:58,060
Like this, so that on the dashboard itself, we can see in text the state of the pump, so I'm going

90
00:07:58,060 --> 00:08:02,230
to place this in the terrarium pump group.

91
00:08:02,230 --> 00:08:07,450
So the pump group, I plan to have information about the status of the pump.

92
00:08:07,900 --> 00:08:18,540
So put it there, leave it to automatic and just say something like pump is pump state is.

93
00:08:18,550 --> 00:08:23,230
And that will give us a one or a zero like this.

94
00:08:25,620 --> 00:08:33,330
As for the label and for the name of the note, I just say pump state, all right, deploy.

95
00:08:33,930 --> 00:08:39,660
And now it looks like this can see one and zero is updated.

96
00:08:43,810 --> 00:08:49,360
And as I usually do with all of my flows, I also want to have a debug.

97
00:08:51,330 --> 00:08:52,110
Our put.

98
00:08:53,430 --> 00:08:57,400
So that I don't have to switch to the dashboard to see what is going on.

99
00:08:57,840 --> 00:09:00,510
So this is going to be a pump state.

100
00:09:04,330 --> 00:09:12,160
That is simply going to give me whatever comes out of manual control on the debug tab right here, because

101
00:09:12,160 --> 00:09:22,260
remember that Alice flew in the next lecture will be able to automatically determine the pump state.

102
00:09:22,540 --> 00:09:29,860
So I would like to be able to see the pump state here in the back window without switching to the to

103
00:09:29,860 --> 00:09:30,580
the dashboard.

104
00:09:30,820 --> 00:09:33,670
OK, so this is enough for the time being.

105
00:09:33,670 --> 00:09:37,360
We can control the pump from our dashboard.

106
00:09:37,930 --> 00:09:41,590
There's a little bit more work to be done here in order to improve it.

107
00:09:41,590 --> 00:09:47,800
But it doesn't make sense to do this now because we really need to implement the part of the flow that

108
00:09:47,800 --> 00:09:54,010
works with the potential mirror or the soil humidity sensor, which will automatically determine the

109
00:09:54,010 --> 00:09:55,810
appropriate pump state.

110
00:09:56,230 --> 00:10:02,440
And that will also probably make another small change here in the pump control part of the flow.

111
00:10:02,890 --> 00:10:05,230
So let's move on to the next lecture.

112
00:10:05,230 --> 00:10:12,070
Where will implement the heart of the terrorism controller, no feat that involves the potential.
