section77 Wiki

5. The Things Network (TTN)

TTN (The Things Network)

TTN-Account anlegen

TTN-Application anlegen

TTN-Device anlegen

Webhook einrichten

Bitte gehe jetzt in das nächste Kapitel "OpenSenseMap (OSeM)", führe dort alle Schritte und komme anschließend hierher zurück.

Payload Decoder einrichten

Gehe in der entsprechenden TTN Application auf das Device, welches du mit OSeM verknüpfen möchtest und öffene anschließend im oberen Reiter den Tab "Payload formatters":

2021-11-30_09-58.png

function Decoder(bytes, port) { // Decode an uplink message from a buffer (array) of bytes to an object of fields.
  var decoded = {};
  if (port === 10) {  // Port selection
    decoded["%%CHANGE_TO_ID_PM_2_5%%"] = (bytes[0] << 16 | bytes[1]<<8 | bytes[2] | (bytes[0] & 0x80 ? 0xFF<<24 : 0))/1000;
    decoded["%%CHANGE_TO_ID_PM_10%%"]     = (bytes[3] << 16 | bytes[4]<<8 | bytes[5] | (bytes[3] & 0x80 ? 0xFF<<24 : 0))/1000;
  }
    return decoded;
}

Quelle für die Basis