Let's have a look at a more comprehensive example now that involves a 22 workflow that you're seeing
here on the floor that you're seeing here, it's disabled at the moment, but I want to publish the
sensor readings to the broker and then get them from the broadcast, subscribe to the program and update
a dashboard or two dashboard widgets with the data we get.
So the first thing I'll do is to enable the flow that these two example flow.
And I'm going to start see around here to set up my publisher.
What I want to do is I want to publish the humidity and Timika values when the DHT 22 generates those
values.
So I'm going to use a complete.
No, so that when this operation here is completed, this note triggers and then it will trigger the
publication of the values for humidity and temperature.
So bear with me.
You'll see what I mean.
I was doing some experimentation a bit earlier and discovered that the DHT 22 note does not emit completion
messages.
So my complete note will not be able to know when this particular note is done is finished.
So I had to use one of these other notes in the function.
Note does work.
So here's what we do.
We go inside.
The complete note will say that I want the complete note to start when the function note up here is
finished.
And I can see that it's selected and I can go ahead and set up its other properties or this only one,
the name property, I give it a name, start when he keeps the history.
Twenty two has new values or something like that will do.
Now what I want to do is to publish
two values.
One is going to be the temperature and the other one is going to be the humidity.
So I'm going to configure those to first.
For the first one is going to be the temperature.
I'm just going to copy some work that I've already done to avoid typos and speed things up a little.
And this is going to be the topic.
So diggity 20 to temperature.
And I want to this to happen using the and quiddity Broca that is on the same Raspberry Pi note read.
For is just leave it a zero.
So that's one, let's do the other immediately out.
The second one is about the humidity, so I give it a name, it's going to publish to this topic and
again, I'm using the client and cure is zero.
Now, the thing is that the 22 actually, I should look at this function here because remember that
the message from this function on completion, which is this will go into into this note, the complete
note, and then it will pass out to whatever note happens to follow.
The problem here is that the immediately out nodes can only grab whatever you've put in the message
payload and then the message payload here contains just this.
Whatever is coming from the age of 22, which if you remember back in the lecture, we looked at the
22 example, the message contains the humidity and the payload.
So unfortunately, I can't grab those individual components from the liquidity.
Eric notes that don't give me this capability.
So I will need to use another function in order to split the two pieces of information into individual
message payloads.
So let's do that.
I'm going to delete those connections and go for a function.
Note and pass the message from the complete note to the function node now inside the function node in
it.
First, I'm going to give it a name.
This is published Temperature and Humidity.
Now for the JavaScript in here, this is all that we need to do.
I've got a an array inside the array.
I've got two very simple chasten documents and each one contains a payload and then the appropriate
payload message.
The payload coming from DHV 22 contains the temperature and then message that humidity contains the
humidity.
And I need to increase my output to two for this function node.
So this is going to go into the top output and this one into the bottom output.
Right.
And now I can do the connections to this one and there is the other.
And that should be enough.
Now, what I'll do to test, because I don't have anything to subscribe to these two topics at the moment
in this flow.
Do that later.
But to test it, I'm going to use my existing and quiddity client in my box so I will delete.
These two don't need them to clean up the available space that I have and I'm going to add two subscribers,
the first subscriber is for the temperature.
Copy that.
Let's make a little bit of space here.
All right, little space, and this is a subscriber to this topic, and let's do one more for the community.
Subscribe to this topic.
All right.
So I started work.
Let's deploy.
That aside, and for this to work and to trigger the DHT 20 to the trigger, and there are.
The message is coming through temperature and humidity.
All right, now let's move on to the next lecture where I'll show you how to use the N.
T in notes to grab the information that we just published to the two topics and initially print them
out to a debugged.
We need to make sure that either work or to a debug note, make sure that the work and then we use dashboard
widgets.