Software apps and online services
This project uses NodeJS,Node-RED, and WolkConnect-Node-RED, an npm package running on Raspberry Pi and its Raspbian OS to connect and send data to WolkAbout IoT Platform. Node-RED supports deployment to Raspberry Pi out of the box, and the set of nodes provided by the package greatly reduces the time needed to connect to the Platform.
To be able to run Node-RED on our Raspberry Pi, you need to install NodeJS. Install NodeJS by running:
curl -sL https://deb.nodesource.com/setup_10.x | bash -
apt-get install -y nodejs
After having installed NodeJS, you can use its package manager to install Node-RED. Make sure to install version
0.20.8 by running:
sudo npm install -g --unsafe-perm email@example.com
Finally, you are ready to install WolkConnect-Node-RED through npm. First, open the terminal and run
node-red. This will make sure that Node-RED sets up all files and directories required for it to run successfully. After the process has successfully reported to have started the flows, it is safe to terminate it. Then, navigate to Node-RED’s folder:
Then install your package by running:
npm install @wolkabout/wolkconnect-node-red
Finally, you are ready to run Node-RED by using the command:
Now, you can navigate to http://127.0.0.1:1880and use Node-RED’s flow editor. The following screen greets you:
WolkConnect nodes should appear at the bottom of the nodes list.
You are now able to use the full potential of NodeJS and Node-RED!
With your package installed, you are ready to set up a device on WolkAbout IoT Platform.
Go to https://demo.wolkabout.com, log in, and navigate to the Devices tab. Then go to Device Templates.
Here you can upload your device template -
full-example-template.json, located in
.node-red/node-modules/@wolkabout/wolkconnect-node-red/examples/full-feature-set. Click on Add Template button, and choose Upload.
Having uploaded the device template, you can create a new device. Click Add Device, and this will take you to the device creation screen, with your newly uploaded template preselected as the device template. Click Next Step.
Enter a device name and select Create semantic group from this device check box. Click Save.
A new popup dialogue appears. Write down device credentials, or download them, and finally click OK. Your device is now ready!
At this point, you are ready to add some widgets to the dashboard on the Platform to be able to visualise the data you are sending. First, you need to create a dashboard, then create widgets.
On the popup dialog, add a new Semantic Group widget.
Select all the available sensors and click Save.
Now add actuator widgets, click Add Widget, and select Actuators.
Select Switch, and click Save.
Repeat the last two steps to add the Slider widget. You have now completed the dashboard setup, and you are ready to set up the Node-RED flow.
Navigate to Node-RED’s flow editor in your browser. Click the hamburger menu in the top-right corner of the browser screen, and select Import >Clipboard.
Copy the contents of
full-example-flow.json located in
.node-red/node-modules/@wolkabout/wolkconnect-node-red/examples/full-feature-set and paste them to the dialogue popup that appeared.
It is also possible to drag the flow file directly onto the browser flow, instead of copying its contents to the import dialogue.
Now that you have imported the flow, you are ready to set up the nodes. But, you need to configure the MQTT nodes first. Double click the MQTT out node, and a new edit dialogue appears.
Edit the WolkAbout Demo server.
On the Connection tab, use your device key as ClientID.
If you want to use a secure connection, select the Enable secure (SSL/TLS) connection check box. Add new TLS config, and upload
ca.pem located in
.node-red/node-modules/@wolkabout/wolkconnect-node-red/examples/, as CA Certificate.
Click Add, and then change the port to 8883.
On the Security tab, pass your device key as Username and your device password as Password.
On the Messages tab, configure your close and disconnect messages in the following manner:
Now, you can go on to set up the MQTT input nodes. All you need to do is pass your device key to the topics, and select WolkAbout Demo as the server. No configuration of the server is needed here, as you have already completed it in the previous steps.
Lastly, pass your device key and password to connect node.
Device configuration and actuators initialiser nodes are already preconfigured for the example flow you are using.
In this example, you are using a device with four sensors, two actuators, and an alarm. Also, you are using
getRandomValue node for providing values to sensors and actuators. Your sensor and actuator nodes are preconfigured for the example you are using, with the sensor and actuator references already passed to them.
Now you can deploy the flow and send the data to WolkAbout IoT Platform.
Click Deploy in the top-right corner of the screen.
If you have entered the data correctly, MQTT nodes will show a connected notification.
Next connect your device to the Platform by clicking the inject node labelled Connect device.
Now check if you have connected your device to the Platform. Go to Devices tab on the Platform, and it should register the device as connected.
Success! The device is connected to the Platform.
Having done this, you can now send readings. Use the inject nodes labelled Send random values from sensors/alarms and Send random values from actuators.
To check for readings, navigate to the Dashboard tab on the Platform.
Great! The readings have been sent to the Platform successfully.
You can also send fixed sensor, actuator, and alarm values by passing the desired value directly to the sensor and actuator nodes, while the configuration node only takes user-defined values. Passing fixed values will ignore random values and send user-defined values to the Platform (note - whenever making changes to nodes/flow, it is necessary to deploy the flow, and use
connect node to reconnect the device to the Platform).
Next, add the value of 50 to your temperature sensor.
And, again, check for the value of temperature sensor on the dashboard once you have redeployed the flow and sent the reading.
To disconnect from the Platform slick the inject node labelled Disconnect device.
The device is now disconnected from the Platform.
With the high degree of customisation and the visual tool Node-RED provides, as well as WolkConnect-Node-RED package, it is straightforward to connect almost any device to WolkAbout IoT Platform. Node-RED contributions library also offers additional packages that further expand the possibilities of Node-RED to run and communicate with various devices, aside from Raspberry Pi used in this example. To learn more about the possibilities of WolkConnect-Node-Red, check the repo’s readme files.
For more information about WolkAbout IoT Platform's features, visit our User Guidespage.