One IoT application development tool for different cloud platforms Azure and Amazon
Today, I would like to share my experience how I have used one tool to build telemetry IoT simulators for different cloud platforms. There were Azure and Amazon platforms.
This story is about one programming tool that helped me to build a flow simulator for sending telemetry data to Azure IoT hub and Amazon IoT at the same time. Before, doing all these stuff you need to configure devices in Azure IoT hub (https://docs.microsoft.com/en-us/azure/iot-hub/quickstart-send-telemetry-dotnet) and in AWS IoT (https://docs.aws.amazon.com/iot/latest/developerguide/register-device.html) as well.
The tool is called Node-RED (https://nodered.org/).
Node-RED is a programming tool for wiring together hardware devices, APIs and online services in new and interesting ways. It provides a browser-based editor that makes it easy to wire together flows using the wide range of nodes in the palette that can be deployed to its runtime in a single click.
Well, let’s create one flow like this below,
In this flow, I have used a few nodes:
- Injects a message into a flow either manually or at regular intervals. The message payload can be a variety of types, including strings, JavaScript objects or the current time.
- A JavaScript function block to run against the messages being received by the node.
- A simple node that sends the message payloads to Azure IoT Hub.
- Connects to a MQTT broker and subscribes to messages from the specified topic.
Let’s take a deeper look at each node.
Injects
Payload filed type should be JSON. For Azure IoT hub message needs to be like this:
- deviceId is your device’s unique id.
- key is your device’s primary or secondary key.
- protocol options are: amqp, amqpws, mqtt or http.
- data can either be a plain string or string wrapped JSON.
Function
The message is passed in as an object called msg
. By convention, it will have a msg.payload
property containing the body of the message.
Azure IoT hub
In this node, you need to put the name of your Azure IoT hub. Do not forget to select the type of protocol. It should be amqp. This node is not installed by default. You need to execute several steps described here — https://flows.nodered.org/node/node-red-contrib-azure-iot-hub
MQTT node
This node requires a connection to a MQTT broker to be configured. First, you need to configure server endpoint.
You need to put a connection address of your AWS IoT. After that, you should configure certificates.
All necessary certificates you can find in AWS IoT console.
The last thing you need to do is deploying the flow by clicking the button “Deploy”.
As the result you can check the telemetry will come in Azure and AWS IoT platforms.
Happy coding.