Connecting Loriot LoRaWAN network server to your IoT Hub

LoRa and Loriot Overview

LoRa is a low-power, low-bandwidth, long-range radio protocol used by many devices to send their data over the air. This protocol is specifically designed for battery powered devices with little to no installation cost.

LoRa devices broadcast their data to reachable LoRa gateways, which forward the messages on the LoRa operator network. The operator de-duplicates the messages from multiple gateways and hand over the message to the “LoRa application”. In our scenario, the “LoRa application” is Scaleway IoT Hub.

Loriot is a LoRaWAN network server provider which to connect your LoRa gateways and build your private LoRa network.

In this tutorial we are going to:

  • Create a IoT Hub which to receive/send messages from/to LoRa devices
  • Add a Device to the Hub to prepare the Loriot-to-Scaleway connection
  • Set up the Loriot backend to use the Device credentials to establish a connection with IoT Hub
  • Add another Device and connect it as a subscriber to receive LoRa messages

Create an IoT Hub

First, we need to create a Hub. Its role will be to distribute messages from your LoRa devices to the intended targets. Please follow this procedure to create an IoT Hub. Choose any name and any plan you wish.

Create an IoT Device

We now need to add a Device to the IoT Hub because the Loriot platform will connect as a MQTT device to exchange data on IoT Hub. Please follow this procedure to do so. Give it the name you want. You should choose allow insecure connection setting. Although data exchanged between Loriot and Scaleway will safely be encrypted with TLS, Loriot doesn’t yet support mutual authentication.

Once it is done, copy the Device ID, you will need it to set up the Loriot backend.

Set up the Loriot backend

Now IoT Hub is ready to exchange messages, let’s configure the Loriot side:

  • Go to your Loriot Dashboard
  • Click on Applications and select your application in the list
  • Click on Output in the left pane, click Add a new output and choose MQTT
  • Fill in the following parameters:
    • MQTT Broker URL: your IoT Hub Endpoint, followed by MQTTs port (ex: iot.fr-par.scw.cloud)
    • MQTT Path: the MQTT topic to publish messages to, set it to my-app/{DEVEUI}/uplink.
    • Username: you can’t leave this field empty, so just write x here, it won’t be used
    • Password: you can’t leave this field empty, so just write x here, it won’t be used
    • Client ID: your IoT Hub Device ID
  • That’s it, click Add Output button

Please note there is an additional step to be performed if you are using a Loriot private network server. You should get in touch with your Loriot representative for this.

Verify we have done things right

It is time to see messages flowing on IoT Hub:

  • Create another IoT Hub Device, but this time choose the allow insecure connection setting to keep this step simple.
  • Let’s open a web based MQTT client such as HiveMQ Websocket Client
  • Connect it to your IoT Hub with the following settings (leave the others untouched):
    • Host: your IoT Hub Endpoint (ex: iot.fr-par.scw.cloud)
    • Port: 80
    • Username: the Device ID for the Device you just created
    • Click on the connect button, the light will turn green and the connection block will collapse
  • Now subscribe to the LoRa devices messages:
    • Click Add New Topic Subscription in the Subscriptions block
    • Pick any color to identify this subscription
    • Choose QoS 0
    • Use my-app/+/uplink as the topic, this will instruct IoT Hub to send you uplink messages from all devices
    • Click subscribe
  • Your subscription now appears in the Subscriptions block and the messages from your LoRa devices will start showing in the Messages block.

Congratulations! Messages are flowing as expected.

Going further

You could leverage the power of IoT Hub to build a dashboard to display your data in a few easy steps:

  • Start a PostgreSQL managed DB instance and create a lora table with the following fields: time (timestamp type) and data (jsonb type)
  • Configure a Database Route to push data in there, see how to. The topic filter should be my-app/+/uplink. Your query should look like INSERT INTO lora (time, data) VALUES (NOW(), $PAYLOAD).
  • Start a new Scaleway instance and setup Grafana, get inspiration from this tutorial (steps 1 to 14, don’t enable TimescaleDB option).
  • Add widgets to your dashboard, for a graph your query could look like SELECT time, data->'bat' as batteryLevel FROM lora WHERE $__timeFilter(time).

That’s it! Your LoRa devices data is now backed by a production-grade dashboard!


Learn more about Scaleway IoT Hub, discover how to add Devices to the hub, check the IoT Hub metrics or get started in a few clicks with the IoT Hub Kickstarts.

Discover a New Cloud Experience

Deploy SSD Cloud Servers in seconds.