1
00:00:00,690 --> 00:00:07,630
In the previous lecture, I give you a very quick introduction of notes inside a note, read and learned

2
00:00:07,650 --> 00:00:12,060
about attributes and a few other things on their own, notes are not very useful.

3
00:00:12,060 --> 00:00:14,640
They can't do anything in order for them to be useful.

4
00:00:14,670 --> 00:00:18,150
They need to be connected and configured inside flows.

5
00:00:18,540 --> 00:00:26,700
So in this lecture, I'm going to show you a few simple examples of notes configured to float to help

6
00:00:26,700 --> 00:00:34,950
us get started before we go into looking at individual nodes and how those connected and useful in our

7
00:00:34,950 --> 00:00:37,530
project and in the context of our project.

8
00:00:38,340 --> 00:00:48,840
To do that, I want to make use of the DHT 22 node that I installed in the previous lecture, and therefore

9
00:00:48,840 --> 00:00:52,690
I'm going to connect eighteen to twenty two cents to my Raspberry Pi.

10
00:00:53,070 --> 00:01:01,410
So first I will need to turn off my Raspberry Pi, install the sensor just on a little header, which

11
00:01:01,410 --> 00:01:08,580
is set up on a little piece of me that I've made and then come back to node read to make use of the

12
00:01:08,580 --> 00:01:09,080
sensor.

13
00:01:09,600 --> 00:01:11,700
So here's my note.

14
00:01:11,700 --> 00:01:13,670
Read Raspberry Pi.

15
00:01:13,680 --> 00:01:16,380
I'm just going to shut down.

16
00:01:17,750 --> 00:01:24,170
And hold, right now, I want to gracefully turn off the Raspberry Pi.

17
00:01:24,260 --> 00:01:28,730
I'm going to go remove power and set up the sensor.

18
00:01:29,330 --> 00:01:37,880
So I suppose now turned off, I can say there's no activity on the grenade and I'm going to unplug network

19
00:01:37,880 --> 00:01:49,520
and power and I'm going to take my DHT 22 sensor and just plug it in to head up high.

20
00:01:50,600 --> 00:01:54,320
And that's all there is to it and to reconnect the network.

21
00:01:56,230 --> 00:01:57,520
And power.

22
00:02:01,050 --> 00:02:03,960
And give my reply, a couple of minutes to begin.

23
00:02:07,120 --> 00:02:09,560
I see no dread it started again.

24
00:02:09,950 --> 00:02:10,400
Not yet.

25
00:02:10,430 --> 00:02:12,170
Still trying to reconnect.

26
00:02:14,720 --> 00:02:18,260
Let's try to refresh the page, it would tell me if the Roseberry prize ready.

27
00:02:21,290 --> 00:02:22,130
And we're back.

28
00:02:22,320 --> 00:02:34,130
OK, so let's have a quick look at some examples I'd like to begin with the inject and debug nodes,

29
00:02:34,310 --> 00:02:38,710
those two together are probably the two simplest nodes.

30
00:02:39,230 --> 00:02:43,580
So I'm going to connect them simply by wiring them together like this.

31
00:02:43,870 --> 00:02:47,750
I double click on the inject node.

32
00:02:47,780 --> 00:02:57,170
You'll see that the inject node allows me to inject a couple of a number of different things to whatever

33
00:02:57,170 --> 00:03:00,590
node follows it or whatever note it is connected to.

34
00:03:01,010 --> 00:03:10,700
For now, I'm just going to type in a string called Hellewell with a with their word halo in it and

35
00:03:11,030 --> 00:03:11,760
click on down.

36
00:03:11,780 --> 00:03:17,870
So the idea here is that when I click on this button, the word halo, which is in the message that

37
00:03:17,870 --> 00:03:25,430
will be stored inside in its G payload variable, will be sent over to the next node, can talk more

38
00:03:25,430 --> 00:03:32,630
about images, thought and physically other types of viable in a dedicated lecture later on in this

39
00:03:32,900 --> 00:03:33,560
section.

40
00:03:34,100 --> 00:03:36,700
So that's all there is for this.

41
00:03:36,710 --> 00:03:38,830
Now, let's go into the payload.

42
00:03:38,860 --> 00:03:39,920
I'm going to give it a name.

43
00:03:40,520 --> 00:03:43,130
Just going to say example, debug.

44
00:03:45,060 --> 00:03:52,440
Node, and you can see that here the output of this node is whatever is inside image or payload, which

45
00:03:52,440 --> 00:03:58,040
is where Halo is stored and this data payload right now.

46
00:03:58,310 --> 00:04:06,960
OK, so for this very simple flow to take effect, we need to deploy it so quickly.

47
00:04:06,960 --> 00:04:07,500
Deploy.

48
00:04:08,720 --> 00:04:14,060
Successfully deployed and click on the bug button so we can see the messages, you can see that will

49
00:04:14,060 --> 00:04:20,620
be showing or will be seeing messages from all nodes, you can be more selective if you want.

50
00:04:20,670 --> 00:04:29,690
You can see right now I clicked on selected nodes and only the single available debug node is showing

51
00:04:29,690 --> 00:04:31,070
and is, of course, selected.

52
00:04:31,500 --> 00:04:33,360
Or he can go for current flows.

53
00:04:33,380 --> 00:04:35,620
You have multiple Smurfs only have one right now.

54
00:04:36,320 --> 00:04:43,520
So to trigger this flow, I just click on the button here, the tech node, and you can see that I do

55
00:04:43,520 --> 00:04:46,790
get notification that the trigger was successful.

56
00:04:46,790 --> 00:04:51,200
And here is the message can change it to something else.

57
00:04:51,210 --> 00:04:57,410
Let's say I can change this to a timestamp and made a change to my flow.

58
00:04:57,410 --> 00:05:03,710
So I need to redeploy it, click and deploy button, click on the trigger button for the inject node.

59
00:05:04,400 --> 00:05:06,030
And this number is actually time.

60
00:05:06,290 --> 00:05:06,680
Right.

61
00:05:07,280 --> 00:05:09,170
Click on a link and see how the time.

62
00:05:10,350 --> 00:05:12,120
Format changes.

63
00:05:14,590 --> 00:05:15,240
All right.

64
00:05:17,210 --> 00:05:19,750
Let's go back to the original as a number.

65
00:05:20,570 --> 00:05:24,410
All right, now let's have a look at another Arsala.

66
00:05:24,440 --> 00:05:27,830
I'm going to click on this button here to add a new flu.

67
00:05:27,980 --> 00:05:28,230
Right.

68
00:05:28,280 --> 00:05:29,180
So this is going to be similar.

69
00:05:29,570 --> 00:05:31,340
Of course, you can give them names.

70
00:05:32,810 --> 00:05:36,680
Can you just double click and say this is going to be two example?

71
00:05:39,570 --> 00:05:41,460
All right, they weren't going to do this.

72
00:05:41,490 --> 00:05:45,900
I'm going to start with the twenty two, so I'm going to set that up first.

73
00:05:48,300 --> 00:05:48,980
Right there.

74
00:05:50,930 --> 00:05:59,690
Double click on it and I'm going to give it a name, DHT 22, I can select the type of sense that it

75
00:05:59,690 --> 00:06:00,410
is.

76
00:06:00,950 --> 00:06:03,680
I'm going to make reference to it.

77
00:06:03,680 --> 00:06:07,520
Terrapin using the PCM chibbaro notation.

78
00:06:07,520 --> 00:06:13,250
And I know that my senses connected to Chibbaro 17.

79
00:06:13,970 --> 00:06:15,950
All right, that's it.

80
00:06:16,040 --> 00:06:17,300
Now on its own.

81
00:06:17,300 --> 00:06:18,820
It can't do anything.

82
00:06:18,830 --> 00:06:25,000
I actually have to trigger it, so I have to basically start it manually.

83
00:06:25,520 --> 00:06:31,670
So there's a couple of ways to do that are probably the easiest way is to use a combination between

84
00:06:31,850 --> 00:06:33,230
a inject.

85
00:06:34,440 --> 00:06:44,910
Flu or note, she'd say, which you saw in the first example and then connected to my DHT, twenty two

86
00:06:44,910 --> 00:06:45,210
cents.

87
00:06:46,650 --> 00:06:50,690
And of course, I don't want to send a timestamp to my 20 cents.

88
00:06:50,700 --> 00:06:56,270
I just want to send that a very simple payload, which could be just a number.

89
00:06:56,760 --> 00:07:02,730
I'm just going to send it something to trigger the D to twenty two to take a reading.

90
00:07:02,940 --> 00:07:03,950
And that's all there is.

91
00:07:03,960 --> 00:07:05,180
That's all you need to do here.

92
00:07:05,190 --> 00:07:10,760
So I'm going to click on OK to get rid of that window.

93
00:07:11,370 --> 00:07:18,480
And the last thing that I want to do is to output the reading from the sensor to the debug window so

94
00:07:18,480 --> 00:07:19,470
you know how to do that.

95
00:07:19,470 --> 00:07:19,850
Right.

96
00:07:20,490 --> 00:07:32,070
Just use debug node connected through and give it a name, show temperature reading and that's going

97
00:07:32,070 --> 00:07:33,420
to come from the payload.

98
00:07:35,150 --> 00:07:40,910
Let's have a look inside here, just in case I think it's all good here, if you want to learn more

99
00:07:40,910 --> 00:07:46,730
about how to use this particular note, remember, there is documentation actually not here, but here

100
00:07:47,630 --> 00:07:49,130
there to the documentation for it.

101
00:07:49,140 --> 00:08:01,280
You can see that the DHT 22 note will store the values from the sensor in the NSG payload variable that

102
00:08:01,280 --> 00:08:02,530
contains the readings.

103
00:08:03,410 --> 00:08:03,860
All right.

104
00:08:03,860 --> 00:08:09,590
So deploy this flu is going to the debug window and then trigger the flu.

105
00:08:10,550 --> 00:08:17,630
And there you go, there is the the reading nineteen point ninety degrees Celsius.

106
00:08:18,360 --> 00:08:25,460
Another thing that I'd like to do here is that instead of me having to click on the button to trigger

107
00:08:25,460 --> 00:08:25,670
it.

108
00:08:26,800 --> 00:08:35,260
Like the flu itself, the trigger DHEA to reading every, say, 10 seconds, so let's see, there's

109
00:08:35,260 --> 00:08:41,980
another useful function here or note, I should say, called Trigger, which is right here.

110
00:08:43,910 --> 00:08:48,920
Have a look at the documentation for Trigger, and it says that when triggered, it can do something

111
00:08:48,920 --> 00:08:50,500
like send the message right.

112
00:08:50,550 --> 00:08:57,650
But what is interesting about it is that you can set a period for the trigger so that it can trigger

113
00:08:58,280 --> 00:09:01,180
whatever follows every few seconds or minutes or even hours.

114
00:09:01,820 --> 00:09:05,840
So have a look at these properties and you see give them more information about this.

115
00:09:05,860 --> 00:09:13,500
So the first part is about setting what happens when you activate the trigger for the first time.

116
00:09:13,940 --> 00:09:16,760
And here we can just set it to center number one.

117
00:09:16,850 --> 00:09:17,130
Right.

118
00:09:17,150 --> 00:09:22,490
But then what's interesting for this particular application is that.

119
00:09:23,680 --> 00:09:31,730
He said, you can respond to the same message every few seconds or milliseconds or minutes or hours.

120
00:09:32,290 --> 00:09:40,540
So what I'll do first, I will delete this wire and then rewire it via the trigger.

121
00:09:40,540 --> 00:09:42,490
Note like this.

122
00:09:45,170 --> 00:09:46,820
I can just rearrange.

123
00:09:48,730 --> 00:09:57,220
The way that the snow is configured and to then makes it a 10 second intervals.

124
00:09:58,440 --> 00:10:03,690
Like this, and I give it a name, get a reading.

125
00:10:04,710 --> 00:10:07,680
Every 10 seconds.

126
00:10:08,880 --> 00:10:18,600
All right, so let's go back to our debark Windu, redeploy this new flu or updated flu, clean up previous

127
00:10:19,290 --> 00:10:24,090
blog, previous messages and then click on the button to trigger.

128
00:10:24,450 --> 00:10:28,010
So here's a first reading and wait for about 10 seconds.

129
00:10:32,850 --> 00:10:38,520
And here is the second reading, and every 10 seconds after that will be getting a new reading from

130
00:10:38,520 --> 00:10:39,120
the censor.

131
00:10:42,640 --> 00:10:43,180
Perfect.

132
00:10:43,690 --> 00:10:50,680
So there's a very simple flow out while we are edit, you can see that if we're going to the information

133
00:10:50,830 --> 00:10:57,880
tab and scroll inside the DHT 20 to flow, it's the tab that we're working on right now.

134
00:10:58,240 --> 00:11:07,540
You can see the nodes that are part of this flow and you can click on each one of those to get the properties

135
00:11:07,690 --> 00:11:08,710
of each node.

136
00:11:12,240 --> 00:11:18,380
One of the really nice features of note read is that it really has built in support for documentation.

137
00:11:18,840 --> 00:11:19,850
I'll show you what I mean.

138
00:11:20,280 --> 00:11:23,420
Double click on any one of those notes, like this one, for example.

139
00:11:23,430 --> 00:11:28,800
And then in the edit pane, you'll see that there is a description tab.

140
00:11:29,310 --> 00:11:34,560
Click on that and you'll see that there is a box where you can type in a document that describes this

141
00:11:34,560 --> 00:11:36,240
particular note and what it does.

142
00:11:36,780 --> 00:11:42,690
So this uses markdown so you can format your documentation appropriately.

143
00:11:42,930 --> 00:11:44,540
It can say something like this.

144
00:11:45,240 --> 00:11:49,020
What is this note about?

145
00:11:50,610 --> 00:12:00,130
And you can formatted this a header and you can say this note triggers the 22 Senso.

146
00:12:02,250 --> 00:12:03,270
Every 10.

147
00:12:05,060 --> 00:12:05,980
Siggins.

148
00:12:07,550 --> 00:12:08,550
OK, that's it.

149
00:12:08,570 --> 00:12:15,770
And now, of course, this documentation appears here for anyone who wants to use it and learn more

150
00:12:15,770 --> 00:12:18,290
about it, but it's also accessible elsewhere.

151
00:12:18,300 --> 00:12:25,850
So, for example, here you see down the bottom, you're going to the information tab for the flow.

152
00:12:25,850 --> 00:12:30,980
You click on the appropriate node and you see down the bottom the documentation appears.

153
00:12:31,670 --> 00:12:34,820
So you can with a bit of care, you can document your project.

154
00:12:34,850 --> 00:12:38,170
It really will as you share them with other people.

155
00:12:38,780 --> 00:12:44,660
I'm going to show you one more very useful feature of node red, which has to do with the ability to

156
00:12:44,660 --> 00:12:47,460
import and export flows.

157
00:12:48,140 --> 00:12:55,190
So let's have a look at my node red installation that is running on my Raspberry Pi four.

158
00:12:55,430 --> 00:12:57,910
And they are I've got this flow.

159
00:12:58,340 --> 00:13:00,950
So this flow contains, again, an inject note.

160
00:13:01,280 --> 00:13:10,250
It's got a function node which contains a bit of JavaScript, and then it's got these three debug notes.

161
00:13:10,670 --> 00:13:18,830
I'd like to export this flow from my Raspberry Pi for and then import them into my Raspberry Pi to.

162
00:13:19,400 --> 00:13:23,210
So what to do that is to go into the menu up here top right.

163
00:13:23,210 --> 00:13:28,910
And then say export and that would take the current flow rate.

164
00:13:29,940 --> 00:13:34,690
And this is the code that describes the contents of this particular flow.

165
00:13:34,760 --> 00:13:35,150
Right.

166
00:13:35,180 --> 00:13:36,890
So it's just text.

167
00:13:37,310 --> 00:13:40,520
I can actually make it format.

168
00:13:40,520 --> 00:13:42,080
It's just adjacent document.

169
00:13:42,410 --> 00:13:46,070
And I want to copy this, the clipboard or you can download it in a text file.

170
00:13:46,080 --> 00:13:52,400
But since I'm working within the browsers now, I can just copy the clipboard.

171
00:13:53,970 --> 00:14:06,540
Done, then go into my note, read local Raspberry Pi and go for input and I can import from clipboard.

172
00:14:08,190 --> 00:14:17,580
Paced and I would like to create a new flow based on this slow document or flow definition, go for

173
00:14:17,580 --> 00:14:21,990
a new flow and import and have a look at this tab.

174
00:14:21,990 --> 00:14:25,110
It contains my newly imported flow.

175
00:14:25,800 --> 00:14:27,990
I can just diploid.

176
00:14:29,710 --> 00:14:39,970
And go to the Dipak window cleaner, previous messages out, actually going to only print out messages

177
00:14:39,970 --> 00:14:44,200
from the current flow rate and then trigger the flow.

178
00:14:44,710 --> 00:14:46,420
You go now.

179
00:14:46,420 --> 00:14:52,630
Well, at this, I just want to share what's happening inside a function notes a double click on that.

180
00:14:52,630 --> 00:14:56,290
And you'll see that in here we have simple JavaScript.

181
00:14:56,590 --> 00:15:05,200
I'm creating a little adjacent document, storing it into a local variable and eventually have three

182
00:15:05,200 --> 00:15:05,710
of those.

183
00:15:06,070 --> 00:15:14,160
And then I can send those out as an array to the right side of the function through three outputs.

184
00:15:14,180 --> 00:15:22,630
So because I've got an array with three items in it, I need to configure the output to have three outputs.

185
00:15:22,630 --> 00:15:27,970
And you can see that I've got one, two, three outputs where this works.

186
00:15:27,970 --> 00:15:35,920
Is that the first message that you're moving things to the right a little so you can have both the added

187
00:15:36,220 --> 00:15:41,190
pain and the graphical representation of the node visible?

188
00:15:41,620 --> 00:15:49,420
So the message one will be available through the first output of the node and message to the second

189
00:15:49,420 --> 00:15:52,000
and to message three from the third.

190
00:15:52,590 --> 00:15:52,880
Right.

191
00:15:52,900 --> 00:16:01,930
Then those messages are captured by the appropriate debug nodes and then print it out and see the first

192
00:16:01,930 --> 00:16:11,080
debug node is called MSJ one message one and it can see its print out here after a triggered the flow

193
00:16:11,260 --> 00:16:12,340
and so on.

194
00:16:12,850 --> 00:16:19,500
I'll be talking more about the functions because functions are of course, extremely powerful.

195
00:16:19,510 --> 00:16:23,950
Anything you can do with JavaScript, any kind of program you can imagine can go in here to the processing

196
00:16:24,820 --> 00:16:29,960
for various inputs and then to create appropriate outputs for further down into the flow.

197
00:16:30,400 --> 00:16:38,320
But this is very useful and I'm going to talk more about the various variables that are available inside

198
00:16:38,320 --> 00:16:46,690
a flow and inside the entire node rate environment so we can actually share data in between flows,

199
00:16:46,840 --> 00:16:54,340
not just inside of itself, but in between multiple flows of the same node rate installation.

200
00:16:55,060 --> 00:17:00,070
OK, so with all that said, let's move on to the next lecture where I'll talk about variables.

201
00:17:00,070 --> 00:17:02,890
And these are global flow and node variables.
