Using Actility as a LoRaWAN© operator for IoT Hub
- Iot-Hub
- LoRaWAN©
- Loriot
LoRaWAN© is a low-power, low-bandwidth, long-range radio protocol used by many devices to send data wirelessly. This protocol is specifically designed for battery-powered devices with little to no installation cost.
LoRaWAN© devices broadcast their data to reachable LoRaWAN© gateways, which forward the messages on the LoRaWAN© operator network. The operator de-duplicates the messages from multiple gateways and hand over the message to the “LoRaWAN© application”. In our scenario, the “LoRaWAN© application” is Scaleway IoT Hub.
Actility is a LoRaWAN© operator which can build a public or private LoRaWAN© network.
In this tutorial we are going to:
- Create an IoT Hub to receive/send messages from/to LoRaWAN© devices
- Add a device to the Hub to prepare the Actility-to-Scaleway connection
- Set up the Actility backend to use the device credentials to establish a connection with IoT Hub
- Add another device and connect it as a subscribe to receive LoRaWAN© messages
You may need certain IAM permissions to carry out some actions described on this page. This means:
- you are the Owner of the Scaleway Organization in which the actions will be carried out, or
- you are an IAM user of the Organization, with a policy granting you the necessary permission sets
- You have an account and are logged into the Scaleway console
- You have configured your SSH key
- You have created an IoT Hub
- You have added a device to your IoT Hub with the Deny Insecure option enabled
Setting up the Actility backend
-
Go to the Actility Thingpark Enterprise console.
-
Click Applications > Create and choose MQTT.
-
Fill in the following parameters (unlisted settings can be anything you like):
- Hostname: Your IoT Hub endpoint, followed by the MQTT port (ex:
iot.fr-par.scw.cloud:8883
). - Account prefix: Enter
my-app
. This allows you to set the MQTT topic prefix. The messages will be published with under a topic such as the following:<prefix>/things/<LoRaWAN device ID>/uplink
. - Protocol:
SSL
. - MQTT Username: Your IoT Hub device ID.
- MQTT Password: Leave this field empty.
- Certificate: The device certificate file (ex:
my-device-crt.pem
). - Private Key: The device key file (ex:
my-device-key.pem
).
- Hostname: Your IoT Hub endpoint, followed by the MQTT port (ex:
-
Click Save.
-
Verify if the Deployment Status is set to Opened in the application page to make sure the application is running.
Your LoRaWAN© network is now connected to your IoT Hub.
Subscribe to the LoRaWAN© devices messages
To ensure messages are being properly sent, we will create a new device that will subscribe to the LoRaWAN© devices messages.
-
Create another IoT Hub device, but this time choose the
Allow Insecure
connections setting. Secured connections are not supported over Web Sockets, which theMQTT Webclient
uses. -
Click MQTT Webclient on the device page. The client will open and connect automatically.
-
Subscribe to the LoRaWAN© devices messages:
- Click Add New Topic Subscription in the Subscriptions block
- Pick any color to identify this subscription
- Leave QoS 0
- Use
my-app/things/+/uplink
as the topic. This will instruct the 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 appear in the Messages block.
Setting up a dashboard
You can go further and leverage the power of IoT Hub to build a dashboard and display your data in a few easy steps:
- Create a Database Instance for PostgreSQL and a
lora
table with the following fields:time
(timestamp type) anddata
(jsonb type). - Configure a Database route to push data into. Set the topic filter as:
my-app/things/+/uplink
. Your query will look like such:INSERT INTO lora (time, data) VALUES (NOW(), $PAYLOAD) - Create an Instance and set up Grafana (You can follow steps 1 to 14 of the tutorial. Do not enable the TimescaleDB option).
- Add widgets to your dashboard.
- Try creating a graph by running the following query:
SELECT time, data->'DevEUI_uplink'->'payload'->'batteryLevel' as batteryLevel FROM lora WHERE $__timeFilter(time)
Learn more about Scaleway IoT Hub, discover how to add Devices to the hub and check the IoT Hub metrics.