Our goal in this lab is to develop an application server that can be used for processing and visualizing IOT data with open source software. The application server can be used with data from any source that supports the ability to output data to an MQTT stream.
These instructions will take you through setting up a Node-RED dashboard.
Note: Windows and Debian Linux were used to develop and validate this project. The same applications can be deployed on other Linux distributions, potentially, with some minor modifications.
In this lab you will
- Set Up the MQTT Data Flow
- Format the Data
- Create a Basic Dashboard
You will need:
- Linux or Windows Host
- Node.js
- Node-RED
- Mosquitto
- MQTT
- Install the latest LTS version of Node.js
- To verify whether this was installed properly run
node -v
andnpm -v
(the system should display what node and npm version is installed on your system)
- To verify whether this was installed properly run
- Install Node-RED locally with npm
- Check whether you installed it correctly by running
node-red
in your terminal - Navigate to http://localhost:1880/ which should automatically direct you to your flow (unless you changed the port number in configuration)
Follow this tutorial on setting up a username and password to secure your Node-RED flows.
- Install Mosquitto
- Make sure it is installed correctly by running
mosquitto -h
in your mosquitto folder- Another way to check is by running
netstat -na
and looking for a listener on port 1883 (unless you changed it from the default in your configuration file)
- Another way to check is by running
Configure your Mosquitto MQTT broker with username and password here
Validate and troubleshoot Mosquitto connectivity and authenication issues here
- Set up your publishing flow like this
- Set up your subscribing flow like this
-
Configure your MQTT nodes by making sure that they have the
same topic
and are on thesame server
- If you set up a username and password, make sure you enter that information into the security tab when you edit the MQTT server
-
You should be able to see the timestamp in your debug window if you press on the inject node
Right now, our timestamp is in a number format, but we want to convert it into a Date. Here we use a function node to format our data.
Your subscribing flow should look like this
Attach a text node and make a new dashboard group and tab to contain it. After clicking on the inject node, your dashboard (at the URL http://localhost:1880/ui/) should look like this.
Your Node-RED flow should look like this
In this lab, you learned how to set up and install Node-RED and Mosquitto (an MQTT broker). You formatted data from the MQTT data stream and created a basic dashboard for people to view.
Check out some extensions to this basic app server
- Improve your UI using our grafana documentation
- Set up email or webex alerts with our node red alert documentation
- Integrate your location data with TAK clients through our node red TAK documentation