In the previous lecture, I give you a very quick introduction of notes inside a note, read and learned
about attributes and a few other things on their own, notes are not very useful.
They can't do anything in order for them to be useful.
They need to be connected and configured inside flows.
So in this lecture, I'm going to show you a few simple examples of notes configured to float to help
us get started before we go into looking at individual nodes and how those connected and useful in our
project and in the context of our project.
To do that, I want to make use of the DHT 22 node that I installed in the previous lecture, and therefore
I'm going to connect eighteen to twenty two cents to my Raspberry Pi.
So first I will need to turn off my Raspberry Pi, install the sensor just on a little header, which
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
sensor.
So here's my note.
Read Raspberry Pi.
I'm just going to shut down.
And hold, right now, I want to gracefully turn off the Raspberry Pi.
I'm going to go remove power and set up the sensor.
So I suppose now turned off, I can say there's no activity on the grenade and I'm going to unplug network
and power and I'm going to take my DHT 22 sensor and just plug it in to head up high.
And that's all there is to it and to reconnect the network.
And power.
And give my reply, a couple of minutes to begin.
I see no dread it started again.
Not yet.
Still trying to reconnect.
Let's try to refresh the page, it would tell me if the Roseberry prize ready.
And we're back.
OK, so let's have a quick look at some examples I'd like to begin with the inject and debug nodes,
those two together are probably the two simplest nodes.
So I'm going to connect them simply by wiring them together like this.
I double click on the inject node.
You'll see that the inject node allows me to inject a couple of a number of different things to whatever
node follows it or whatever note it is connected to.
For now, I'm just going to type in a string called Hellewell with a with their word halo in it and
click on down.
So the idea here is that when I click on this button, the word halo, which is in the message that
will be stored inside in its G payload variable, will be sent over to the next node, can talk more
about images, thought and physically other types of viable in a dedicated lecture later on in this
section.
So that's all there is for this.
Now, let's go into the payload.
I'm going to give it a name.
Just going to say example, debug.
Node, and you can see that here the output of this node is whatever is inside image or payload, which
is where Halo is stored and this data payload right now.
OK, so for this very simple flow to take effect, we need to deploy it so quickly.
Deploy.
Successfully deployed and click on the bug button so we can see the messages, you can see that will
be showing or will be seeing messages from all nodes, you can be more selective if you want.
You can see right now I clicked on selected nodes and only the single available debug node is showing
and is, of course, selected.
Or he can go for current flows.
You have multiple Smurfs only have one right now.
So to trigger this flow, I just click on the button here, the tech node, and you can see that I do
get notification that the trigger was successful.
And here is the message can change it to something else.
Let's say I can change this to a timestamp and made a change to my flow.
So I need to redeploy it, click and deploy button, click on the trigger button for the inject node.
And this number is actually time.
Right.
Click on a link and see how the time.
Format changes.
All right.
Let's go back to the original as a number.
All right, now let's have a look at another Arsala.
I'm going to click on this button here to add a new flu.
Right.
So this is going to be similar.
Of course, you can give them names.
Can you just double click and say this is going to be two example?
All right, they weren't going to do this.
I'm going to start with the twenty two, so I'm going to set that up first.
Right there.
Double click on it and I'm going to give it a name, DHT 22, I can select the type of sense that it
is.
I'm going to make reference to it.
Terrapin using the PCM chibbaro notation.
And I know that my senses connected to Chibbaro 17.
All right, that's it.
Now on its own.
It can't do anything.
I actually have to trigger it, so I have to basically start it manually.
So there's a couple of ways to do that are probably the easiest way is to use a combination between
a inject.
Flu or note, she'd say, which you saw in the first example and then connected to my DHT, twenty two
cents.
And of course, I don't want to send a timestamp to my 20 cents.
I just want to send that a very simple payload, which could be just a number.
I'm just going to send it something to trigger the D to twenty two to take a reading.
And that's all there is.
That's all you need to do here.
So I'm going to click on OK to get rid of that window.
And the last thing that I want to do is to output the reading from the sensor to the debug window so
you know how to do that.
Right.
Just use debug node connected through and give it a name, show temperature reading and that's going
to come from the payload.
Let's have a look inside here, just in case I think it's all good here, if you want to learn more
about how to use this particular note, remember, there is documentation actually not here, but here
there to the documentation for it.
You can see that the DHT 22 note will store the values from the sensor in the NSG payload variable that
contains the readings.
All right.
So deploy this flu is going to the debug window and then trigger the flu.
And there you go, there is the the reading nineteen point ninety degrees Celsius.
Another thing that I'd like to do here is that instead of me having to click on the button to trigger
it.
Like the flu itself, the trigger DHEA to reading every, say, 10 seconds, so let's see, there's
another useful function here or note, I should say, called Trigger, which is right here.
Have a look at the documentation for Trigger, and it says that when triggered, it can do something
like send the message right.
But what is interesting about it is that you can set a period for the trigger so that it can trigger
whatever follows every few seconds or minutes or even hours.
So have a look at these properties and you see give them more information about this.
So the first part is about setting what happens when you activate the trigger for the first time.
And here we can just set it to center number one.
Right.
But then what's interesting for this particular application is that.
He said, you can respond to the same message every few seconds or milliseconds or minutes or hours.
So what I'll do first, I will delete this wire and then rewire it via the trigger.
Note like this.
I can just rearrange.
The way that the snow is configured and to then makes it a 10 second intervals.
Like this, and I give it a name, get a reading.
Every 10 seconds.
All right, so let's go back to our debark Windu, redeploy this new flu or updated flu, clean up previous
blog, previous messages and then click on the button to trigger.
So here's a first reading and wait for about 10 seconds.
And here is the second reading, and every 10 seconds after that will be getting a new reading from
the censor.
Perfect.
So there's a very simple flow out while we are edit, you can see that if we're going to the information
tab and scroll inside the DHT 20 to flow, it's the tab that we're working on right now.
You can see the nodes that are part of this flow and you can click on each one of those to get the properties
of each node.
One of the really nice features of note read is that it really has built in support for documentation.
I'll show you what I mean.
Double click on any one of those notes, like this one, for example.
And then in the edit pane, you'll see that there is a description tab.
Click on that and you'll see that there is a box where you can type in a document that describes this
particular note and what it does.
So this uses markdown so you can format your documentation appropriately.
It can say something like this.
What is this note about?
And you can formatted this a header and you can say this note triggers the 22 Senso.
Every 10.
Siggins.
OK, that's it.
And now, of course, this documentation appears here for anyone who wants to use it and learn more
about it, but it's also accessible elsewhere.
So, for example, here you see down the bottom, you're going to the information tab for the flow.
You click on the appropriate node and you see down the bottom the documentation appears.
So you can with a bit of care, you can document your project.
It really will as you share them with other people.
I'm going to show you one more very useful feature of node red, which has to do with the ability to
import and export flows.
So let's have a look at my node red installation that is running on my Raspberry Pi four.
And they are I've got this flow.
So this flow contains, again, an inject note.
It's got a function node which contains a bit of JavaScript, and then it's got these three debug notes.
I'd like to export this flow from my Raspberry Pi for and then import them into my Raspberry Pi to.
So what to do that is to go into the menu up here top right.
And then say export and that would take the current flow rate.
And this is the code that describes the contents of this particular flow.
Right.
So it's just text.
I can actually make it format.
It's just adjacent document.
And I want to copy this, the clipboard or you can download it in a text file.
But since I'm working within the browsers now, I can just copy the clipboard.
Done, then go into my note, read local Raspberry Pi and go for input and I can import from clipboard.
Paced and I would like to create a new flow based on this slow document or flow definition, go for
a new flow and import and have a look at this tab.
It contains my newly imported flow.
I can just diploid.
And go to the Dipak window cleaner, previous messages out, actually going to only print out messages
from the current flow rate and then trigger the flow.
You go now.
Well, at this, I just want to share what's happening inside a function notes a double click on that.
And you'll see that in here we have simple JavaScript.
I'm creating a little adjacent document, storing it into a local variable and eventually have three
of those.
And then I can send those out as an array to the right side of the function through three outputs.
So because I've got an array with three items in it, I need to configure the output to have three outputs.
And you can see that I've got one, two, three outputs where this works.
Is that the first message that you're moving things to the right a little so you can have both the added
pain and the graphical representation of the node visible?
So the message one will be available through the first output of the node and message to the second
and to message three from the third.
Right.
Then those messages are captured by the appropriate debug nodes and then print it out and see the first
debug node is called MSJ one message one and it can see its print out here after a triggered the flow
and so on.
I'll be talking more about the functions because functions are of course, extremely powerful.
Anything you can do with JavaScript, any kind of program you can imagine can go in here to the processing
for various inputs and then to create appropriate outputs for further down into the flow.
But this is very useful and I'm going to talk more about the various variables that are available inside
a flow and inside the entire node rate environment so we can actually share data in between flows,
not just inside of itself, but in between multiple flows of the same node rate installation.
OK, so with all that said, let's move on to the next lecture where I'll talk about variables.
And these are global flow and node variables.