This repository contains an application for adapting MQTT messages to Azure IoTHub. It uses Mosca as MQTT broker and the Azure IoT Node.JS SDK to send messages to IoTHub.
NOTE: Azure IoTHub now supports MQTT natively (take a look at the article).
This application currently only supports device to cloud messages.
Clone the repository, then run
npm install
to install all needed packages.
In connection.js
change the contents of variable "hubName" to your IoTHub name.
Configure the following client fields on your MQTT client:
password=DeviceKey
username=DeviceId
topic=DeviceId/Topic
The application will then forward this information to the devicespecific endpoint at Azure IoTHub.
You can optain the information on DeviceKey and DeviceId by using Device Explorer.
To run the application execute
node app.js
To test or preview the functionality you can edit the file client.js
and enter your IoTHub credentials. The script will send 100 Messages to IoTHub (one message per second). You can see the incoming messages by using Device Explorer.
To run this script execute
node client.js
on the same system that runs the main protocol gateway application.