|
This recipe focuses on the integration of SmartMesh IP into HiveMQ. If you don't know what HiveMQ and/or MQTT is, we recommend the excellent getting started guides from HiveMQ. |
The goal of this recipe is to get you started integrating your SmartMesh IP network into HiveMQ. After following these steps, you will be able to explore all the possibilities HiveMQ offers.
MQTT is a system which allows computers to publish messages to a broker. Each message is attached a topic (e.g. "dustcloud/temperature"). MQTT also allows computers to subsribe to certain topics. MQTT is scalable (i.e. many computers can be publishing/subscribing to many messages at the same time) and has several security options.
HiveMQ is a company which sells an MQTT broker with all the features (security, scalability, support...) appropriate for Enterprise solutions.
In this recipe, we show you atomic integration examples between your SmartMesh IP network and MQTT, enough to get you started on more complete integration for your application.
We start with the most straightforward use case of HiveMQ: (sensor) data publishing.
Here is what the system you will build does:
In a nutshell, add publish/subscribe capabilities to your SmartMesh IP network in a couple of clicks!
Your browser is now connected to HiveMQ's demo MQTT broker. Easy, right? |
It is possible that you get the following message after clicking the "Connect" button. This is because your firewall prevents you from communicating with the HiveMQ demo MQTT broker over port 8000. Contact you network or system administrator. |
dustcloud
TopicOn the right-hand side, add a new subscription to the "dustcloud/temperature" topic.
You will get a notification anytime someone connected to the same MQTT broker sends a message to this topic. That's exactly what we will do below. |
Switch on your SmartMesh IP manager and motes
We assume all SmartMesh IP motes are running the default firmware in master mode, and publish temperature data every 30 seconds. |
Start the SmartMesh IP JsonServer application and Node-RED, and connect the JsonServer application to your SmartMesh IP manager's serial API port.
See the SmartMesh IP and Node-RED, revisited recipe to see how to do that. |
Your SmartMesh IP network is running, and the All you have to do now is have Node-RED publish those sensor measurements to your HiveMQ demo MQTT broker! |
Almost there, this is the last step!
All we need to do is create a Node-RED flow which:
/oap
to receive the OAP notifications form the JsonServer
This is what the resulting Node-RED flow looks like:
|
You can now see the notifications on any MQTT client in the world which is connected to this broker and subscribed to the "dustcloud" topic:
using HiveMQ's websocket's client | using a smart phone app (here MQTTool for iOS) |
---|
That's it! You are now pushing data into one the most convenient and efficient publish/subscribe systems! Enjoy! (but keep reading to see another use case and some important discussion) |
Your SmartMesh IP mote can interface to virtually any sensor and actuator through analog and digital interfaces. The default firmware which is pre-loaded allows you to emulate this by doing the simplest remote actuation: setting an LED.
The TempMonitor sample application (part of the SmartMesh SDK) allows you to actuate a mote's LED from the manager. In this section, we take it one step further, and allow your to actuate and LED from the cloud!
We use the exact same setup as before, all we will do is change the Node-RED flow.
All we need to do is create a Node-RED flow which:
This is what the resulting Node-RED flow looks like:
|
On your HiveMQ websocket client, publish the following message to the "dustcloud/led" topic
{ "mac": "00-17-0d-00-00-38-07-18", "value": 1 } |
Set value to "1" to switch the LED on, set to "0" to switch it off.
Of course, replace the MAC address ( |
Tada, the LED changes state!
Any MQTT client connected to that broker can issue the same message. This means your can trigger actuation from anywhere in the world, using any type of device, including your smart phone. |
This recipe doesn't even scratch the surface of what HiveMQ and MQTT allow you to do.
Things you can build now:
Security MUST be taken seriously in all applications, including end-to-end IoT solutions like the one we are building here. This recipe is minimal by design, and doesn't detail nor contain the level of security you need for a production system. Things we haven't touched upon:
When building a production system, we strongly recommend implementing industry-standard security methods. |
Some links for your further exploration.