From RevSpace
Revision as of 09:56, 5 April 2021 by Bertrik Sikken (talk | contribs) (What is this)
Jump to navigation Jump to search
Project LoraLuftdatenForwarder
LoRaWAN forwarder for particulate matter data
Status In progress
Contact bertrik
Last Update 2021-04-05

What is this

This is a companion project of LoraWanDustSensor.

It is a Java application that takes airborne particulate matter measurement data transferred through TheThingsNetwork and forwards it to http://sensor.community (formerly Luftdaten) and http://opensensemap.org .

Next steps:

  • add support for NB-IOT modem with t-mobile backend, see my Sim7020 project


You need the following:

  • a server that is always on and connected to the internet, can be Linux or Windows
  • a Java installation (JDK to compile), at least version 8
  • some configuration on TheThingsNetwork side
  • some configuration of my application (YAML file)


To compile the software:

  • clone the software from my github archive
 git clone https://github.com/bertrik/LoraLuftdatenForwarder.git
  • enter the LoraLuftdatenForwarder/gradle directory
 cd LoraLuftdatenForwarder/gradle
  • run the gradle script to build the software:
 ./gradlew assemble
  • the application zip & tar is now available in LoraLuftdatenForwarder/LoraLuftdatenForwarder/build/distributions

To update to the latest version:

  • Update software from github archive:
 git pull
  • perform the last two steps above again


Unzip the distribution file somewhere on your system. I put it in my home directory, for example

 tar xvf code/LoraLuftdatenForwarder/LoraLuftdatenForwarder/build/distributions/LoraLuftdatenForwarder.tar


Node configuration

The particulate matter measurement device needs to send data in the Cayenne format. I used the following conventions:

  • PM10 is encoded as analog value on channel 1
  • PM2.5 is encoded as analog value on channel 2
  • PM1.0 is encoded as analog value on channel 0 (optional)
  • PM4.0 is encoded as analog value on channel 4 (optional)
  • Temperature is encoded using standard Cayenne encoding (optional)
  • Humidity is encoded using standard Cayenne encoding (optional)
  • Barometric pressure is encoded using standard Cayenne encoding (optional)

TheThingsNetwork application/device configuration

TTN API key rights

You need to define an 'application' on TheTheThingsNetwork.

  • Go the TTN console: https://console.cloud.thethings.network/ and log in
  • You need an 'application', create a new one, or use an existing one
  • Within the application you need a 'device', so create a new one, or use an existing one:
    • Use OTAA, LoRaMac version probably 1.0.3
    • Enter the device EUI as displayed on the display
    • Use the application keys as specified in my LoraWanDustSensor page
  • You need an API key
    • Create this on the TTN console, grant individual rights as shown in the screenshot
    • NOTE: you have only one chance to copy this key somewhere, so copy/paste it locally to a text file or something

LoraLuftdatenForwarder configuration

To configure the application:

  • Start the application without a configuration file, this will create a default template, stop the application again
 cd LoraLuftdatenForwarder
  • Edit the loraluftdatenforwarder.yaml file, example:
  mqtt_url_v2: "tcp://eu.thethings.network"
  mqtt_url_v3: "tcp://eu1.cloud.thethings.network"
  identity_server_url: "https://eu1.cloud.thethings.network"
  identity_server_timeout: 20
  - name: "particulatematter"
    version: "V3"
    key: "NNSXS......."
    encoding: "CAYENNE"
  url: "https://api.sensor.community"
  timeout: 20
  url: "https://api.opensensemap.org"
  timeout: 20
    "0ttn-deveui-here": "put-opensense-boxid-here"
    "0004A30B001E00BE": "5eca4a0fd0545b001c0e5d46"


  • enter the name of your application
  • enter the TTN API key you saved earlier
  • other defaults are probably OK



  • Go to https://devices.sensor.community/ and log in
  • Register a node with id 'TTN-<device-EUI-as-shown-on-display>'
  • Register it with the proper configuration, e.g. SDS011 with BME280


  • Go to opensensemap.org and log in
    • Create an opensense node with the proper configuration
    • Copy the opensensenmap 'box id', a long hexadecimal string
  • Go the TTN console: https://console.cloud.thethings.network/ and log in
    • Add an attribute for the device, under 'General settings', name = 'opensense-id', value = 'box id' (without the quotes) that you copied from opensensemap.org
  • The boxid should be picked up automatically by the forwarder, within an hour