You want to connect your NB-IoT device to your MQTT client, but the NB-IoT modem only supports UDP…
With the Orange Maker IoT platform this can be easily achieved. The platform has a UDP endpoint that receives the data from your device, the data is internally forwarded to the MQTT broker where you can subscribe too with your MQTT client.
This tutorial provides an easy example of sending an incremental counter value to Orange Maker and subscribe with an MQTT client to the data feed.
Step 1 Creating your device in Orange Maker and uploading the Counter sketchIf you have not yet used your Orange Rapid Development Kit yet, here is how to get started
Otherwise you can find the sketch with the counter example in Arduino IDE under File >> Examples >> arduino-nbiot-sdk-master >> counter.
You will already have created the device in Orange Maker, no need to change anything.
Upload the counter sketch to the Mbili board. Once the board is connected to the NB-IoT network, check if the counter value is incremented in Orange Maker in the asset list of your device.
Step 2 Configuring MQTT.fx client connectionOf course you will first need to have MQTT.fx installed. When you open it, first you need to configure the MQTT broker connection profile. Click on the settings icon next to the connect button.
In the connection profile, click on the + in the left lower corner to add a new profile.
Give the profile a name. For example Orange Maker MQTT Broker.
Profile Type: MQTT Broker
Broker Address: api.allthingstalk.io
Broker Port: 1883
Client ID, click on generate.
For the User Credentials, you will need the Device Token from Orange Maker. Go to your device in Orange Maker, you will find it under Settings >> Authentication. Click the copy icon next to the Device Token and paste it into the User Name under User Credentials. For the password, you can fill in any kind.
Once all set you can click on Apply. Time to connect to the MQTT broker.
Step 3 Subscribing to the MQTT brokerSelect your newly created broker profile and click connect.
Once connection is established, you can fill in the subscribe topic. You can subscribe to the data feed of an asset, but also use a wildcard to receive all asset data of the device.
Below is the topic strings you need to use, copy paste your Device ID from Orange Maker and if need fill in the asset name
Subscribing to only one asset
device/<Your device id>/asset/<asset name>/feed
For the counter asset this will look like
device/<Your device id>/asset/counter/feed
Subscribing to all assets of a device using a wildcard
device/<Your device id>/asset/+/feed
Choose which on to use, fill in under Subsribe in MQTT.fx.
Once done, click subscribe. The data feed will start.
Now you have an NB-IoT to MQTT data forwarder. Wasn’t that easy?
If you have subscribed to all assets of the device, you can also upload the other examples for the Orange Rapid Development Kit. Just connect the sensors and upload the sketch to the board.
Here is are the links to the other examples
- Count visits | count visits for just-in-time facility maintenance
- Environmental sensing | measure your surroundings
- Guard your stuff | lock your bike and get notified when it moves
Do not forget to set the subscribe topic in MQTT.fx to all assets of the device.
device/<Your device id>/asset/+/feed
Have fun!
Comments