Sending data from a device to Microsoft Azure IoT Hub
- The device must be registered with Microsoft Azure IoT Hub.
- The controller must be connected to the internet.
- Open Node-RED.
- Add the following nodes to the workspace and connect them to a flow:
- inject node from the input category
- Azure IoT Hub node from the cloud category
- debug node from the output category
- Double-click the inject node to open the Edit node dialogue.
- In the text box Payload, enter a message as JSON in the following format:
NOTICE


{ "deviceId": "yourDeviceId","key": "eitherYourPrimaryOrYourSecondaryKey","protocol": "egMqtt","data": "yourData"}NOTICE


You can replace the inject node with any node, that generates similar messages.
- Click Done to apply your changes.
- Double-click the Azure IoT Hub node to open the Edit node dialogue.
- In the drop-down list Protocol, select the protocol you want to use.
- In the text box Hostname, enter your hostname.
- Click Done to apply your changes.
- Click Deploy.
- Click the button on the left side of the inject node.
- The configured message is sent to Azure IoT Hub. The status of the Azure IoT Hub node changes to Sent message.