Robin avatar

Node-Red Tabs on Raspberry Pi

robingreig

Published: 11 Jan 2021 › Updated: 11 Jan 2021Node-Red Tabs on Raspberry Pi

Node-Red Tabs on Raspberry Pi

Good Morning! In my previous post on using mqtt with Node-Red, mytechtrailHive account@mytechtrail had asked how to add different tabs for the different flows that could be on separate Pi's. Additionally I'll share with you a public mqtt broker that you could use if you wanted to control your flows from anywhere without having to open a port in your firewall. I know enough about security to know that I don't have the skills to be opening ports while keeping the bad guys at bay! (grin)

image.png As mentioned previously, I originally had the switch (GPIO24) connected straight to the output (PIN18), however I'm now having the switch send a mqtt message to the public broker so generously provide by HiveMQ and if you have a few moments you want to read their awesome mqtt essentials series, that does a great job of explaining mqtt.

image.png
To add the hivemq broker double-click on the pink mqtt node and click on the down arrow on the Server box and select "Add new mqtt broker". Now click the pencil button to the right.

image.png I labeled mine "HiveMQ" and the Server address is broker.hivemq.com and click "Add"

image.png From what I understand, your topic should start with "testtopic/YourUniqueName". I've called mine "testtopic/robin1" and I've set QOS = 2 to assure delivery.

image.png

Don't forget to set the same broker and topic on the incoming mqtt node.
Deploy the changes and double check that your GPIO pin is going high & low as you move the switch on and off. You are now sending your mqtt message out to their public broker and you have subscribed to it and are receiving it back. If you want to manually test the message you can use their online browser client to publish messages to your topic and verify that you are receiving them.

image.png To setup a separate tab on the UI (User Interface = the webpage) lets add another switch > mqtt out & mqtt in > GPIO.

image.png Double clicking on the switch node brings up this screen and it defaults to the "Home" tab and "My First Group" group that we had setup earlier.

image.png Go ahead and click on the dropdown arrow on the Group and select "Add new ui_group"

image.pngClick on the pencil to bring up this screen

image.pngClick on the dropdown arrow on the Tab and select "Add new ui_tab"

image.png
Click on the pencil and rename your new tab "Away" and click Add

image.png
Rename the second group from "Default" to "My Second Group" and click Add

image.png
Now your switch node should have a Group of [Away] My Second Group and click Done

image.png
Click on the mqtt node and set the server to "HiveMQ", the topic to something new "testtopic/robin2" and the QOS to 2 for assured delivery, and click Done

image.png
Do the same for the mqtt in node

image.png
And set the GPIO pin to your desired number, and don't forget to select "Initialize pin state" if you want it to start in a Low or High state, and click Done

image.png
All the red triangles should be gone indicating that you configured all of the nodes and the blue circles will disappear once you've deployed the changes

image.png
You did remember to deploy the changes right? (grin)

image.png
Now when you goto the UI "yourPiAddress:1880/ui" and click on the 3 bars beside the Home tab in the upper left corner you should see Home and Away (the new tab you've created)

image.png
Selecting "Home" brings up the GPIO24 switch in "My First Group"

image.png
And selecting "Away" brings up the second switch in "My Second Group".

Hopefully this has shown you how you can add access to many of your different devices through Node-Red and because we are using mqtt we can control the outputs or receive input from Node-Red devices and the Pi ZeroW's running their python3 code.
Thanks for viewing!
Robin

Leave Node-Red Tabs on Raspberry Pi to:

Written by

Raspberry Pi, Arduino, Node-Red, Python3, mqtt, Electronics, Ham Radio

Read more #raspberrypi posts


Best Posts From Robin

We have not curated any of robingreig's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From Robin