ChirpStack LoRaWAN Integration
ChirpStack is an open source LoRaWAN network server stack. This tutorial explains how to receive LoRaWAN sensor data via ChirpStack using the MQTT Agent. The tutorial is based on the Dragino LHT65 LoRaWAN sensor device as an example.
Install and start ChirpStack
- Make a copy of the ChirpStack Docker repository with the following commands:
git clone https://github.com/brocaar/chirpstack-docker.git
cd chirpstack-docker
- Start ChirpStack
docker-compose up
- Login to the ChirpStack UI (
http://localhost:8080/
admin/admin
)
Create the ChirpStack LoRaWAN Gateway
- Navigate to the
Service-profiles
page and click the+ Create
button. - Create a service profile with the following settings:
- Add gateway meta-data:
enabled
- Enable network geolocation:
enabled
- Minimum allowed data-rate:
0
- Maximum allowed data-rate:
5
(Europe),4
(US)
- Add gateway meta-data:
- Navigate to the
Gateways
page and click+ Create
button. - Create a gateway with the following settings:
- Gateway ID: 8 byte hexadecimal number (e.g. a841452101b04161, see gateway device manual for how to retrieve the gateway ID)
- Network-server:
docker-network-server
- Service-profile: service profile you created earlier
Create the ChirpStack LoRaWAN Device
- Navigate to the
Applications
page and click the+ Create
button. - Create an application with the following setting:
- Service-profile: service profile you created earlier
- Navigate to the
Device-profiles
page and click the+ Create
button. - Create a device profile with the following settings:
- General:
- LoRaWAN MAC version: see device manual (select
1.0.3
in case of Dragino LHT65) - LoRaWAN Regional Parameters revision: see device manual (select
A
in case of Dragino LHT65) - Max EIRP:
14
(Europe) - Uplink interval (seconds): see device configuration (select
1200
in case of Dragino LHT65)
- LoRaWAN MAC version: see device manual (select
- JOIN (OTAA/ABP):
- Device supports OTAA:
enabled
- Device supports OTAA:
- CODEC:
- Custom JavaScript decoder function: add a function that decodes the base64 encoded binary data (in case of the Dragino LHT65 go to the Dragino LHT65 support page in order to download a ChirpStack data decoder).
- General:
- Navigate to the
Applications
page and select the application you created earlier - On the
Devices
tab click the+ Create
button. - Create a device with the following settings:
- General:
- DeviceEUI: 8 byte hexadecimal number (see LoRa device manual for how to retrieve this identifier from the device).
- Device-profile: device profile you created earlier
- General:
- Navigate to the
KEYS (OTAA)
tab and configure the new device with the following setting:- Application key: 16 byte hexadecimal number (see device manual for how to retrieve the application key from the device).
Create the OpenRemote MQTT agent
- Login to the OpenRemote manager UI (
https://localhost/
admin/secret
) - Navigate to the
Assets
page, click+
in the asset tree on the left. - In the
Add asset
dialog do the following:- Select the
MQTT Agent
asset type in the list - Name:
ChirpStack MQTT Agent
- Confirm with
ADD
- Select the
- Click
Modify
and configure the following asset attributes:- Host: IP address of the ChirpStack server (e.g. 192.168.170.83)
- Port:
1883
- Confirm with
SAVE
Create the OpenRemote LoRaWAN device asset
-
Navigate to the
Assets
page, click+
in the asset tree on the left. -
In the
Add asset
dialog do the following:- Select the
Thing Asset
type - Name:
Dragino LHT65
- Confirm with
ADD
- Select the
-
Click
Modify
-
Click
ADD ATTRIBUTE
and do the following in theAdd attribute
dialog:- Type:
Custom attribute
- Name:
Temperature
- Value type:
Number
- Confirm with
ADD
- Type:
-
Expand the
Temperature
attribute and clickADD CONFIGURATION ITEMS
-
In the
Add configuration items
dialog do the following:- Select
Agent link
in the list - Confirm with
ADD
- Select
-
Expand the
Agent link
configuration item and configure theAgent ID
:- Agent ID:
Chirpstack MQTT Agent
- Agent ID:
-
Click
ADD PARAMETER
in order to add the MQTT topic configuration. -
In the
Add parameter
dialog do the following:- Select
Subscription Topic
- Confirm with
ADD
- Select
-
Edit the
Subscription Topic
.The ChirpStack MQTT topic for sensor values has the following format:
application/{application id}/device/{deviceEUI}/event/up
application id: see Applications list in the Chirpstack UI
deviceEUI: 8 byte hexadecimal LoRaWAN device identifierExample for the
Subscription Topic
value:application/1/device/a841452101b04161/event/up
-
Click
ADD PARAMETER
in order to add a json path configuration. -
In the
Add parameter
dialog do the following:
- Select
Value Filters
- Confirm with
ADD
- Expand the new
Value Filters
parameter and clickADD ITEM
- In the
Add item
dialog do the following:
- Select
JSON Path
- Confirm with
ADD
- Expand the new
JSON Path
item and do the following:
- Path:
$.object.TempC_DS
(Note: this is an example for the Dragino LHT65 data decoder) - Return First:
enabled
The following json structure shows an example of the Dragino LHT65 MQTT topic value:
{
"applicationID":"1",
"applicationName":"dragino-lht65-application",
"deviceName":"dragino-lht65",
"deviceProfileName":"lht65-profile",
"deviceProfileID":"c3eb48d6-eddc-4038-bee9-1d5855d98d90",
"devEUI":"a841452101b04161",
"rxInfo":[
{
"gatewayID":"3499452178b04155",
"uplinkID":"a1da5994-04c9-4bb7-ad2d-088c8668d2d1",
"name":"dragino-lg308",
"rssi":-55,
"loRaSNR":9.5,
"location": {
"latitude":8.232323023,
"longitude":7.8383283838,
"altitude":664}
}
],
"txInfo": {
"frequency":868100000,
"dr":5
},
"adr":true,
"fCnt":2064,
"fPort":2,
"data":"y+AG5wFZAQawf/8=",
"object": {
"BatV":3.04,
"Ext_sensor":"Temperature Sensor",
"Hum_SHT":"34.5",
"TempC_DS":"17.12",
"TempC_SHT":"17.67"
}
}
- Click
SAVE