Giter Club home page Giter Club logo

node-red-decoder_lora's Introduction


Logo

TTN-Node-Red-Decoder

Project is aimed to use the Node-Red to decode TTN raw data
Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents

  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. License
  6. Contact

About The Project

In this project we are going to explore how to decode raw data from The Things Stack Community Edition applications we have created. In this example we cannot use the decoder in The Things Stack Community Edition as the decoder is larger than 4k, but you can use this on any size decoder.

TTN Node Red Decoder

Built With

  • Node-Red

Getting Started

To get a local copy up and running follow these simple steps.

Prerequisites

  • Node-Red
    https://nodered.org/docs/getting-started/

Installation

Install Node-Red following the relevant getting started guide for your operating system form the official website

https://nodered.org/docs/getting-started/

Usage

I have some Abeeway Smart barges and micro trackers, the decoder for them are more the 4k so you can’t utilize the decoder on the “The Things Stack Community Edition”, here I am going to use Node-Red to decode the raw data for me. In the same way you can use the decoder for both small and large packet decoders.

  1. Create your application in TTN, add you device to the application.

Logo

  1. In the integration add MQTT , copy your “Public TLS address”, “Username” and “Generate new API key”

Logo

  1. Head over to your Node-Red instance and add a MQTT node to your flow, set up using https://www.thethingsnetwork.org/forum/t/mqtt-in-node-red-howto/39909

  2. Add a “function” node and some “debug” nodes (these are just for debug purposes) and wire the lot together. I have an additional “inject” node just to simulate the JSON from TTN.

Logo

  1. In the “inject” node (Simulate mqtt from TTN) you can past the below (remember this is the JSON from TTN for an Abeeway tracker) in the msg.payload, you also need to change the payload type to JSON. The structure from TTN are the same for all nodes. And then select “Done”. {"topic":"v3/smart-badge@ttn/devices/sotracking-abeeway-smartbadge-1/up","payload":{"end_device_ids":{"device_id":"sotracking-abeeway-smartbadge-1","application_ids":{"application_id":"smart-badge"},"dev_eui":"ttnPacketSim","join_eui":"ttnPacketSim2","dev_addr":"ttnPacketSim3"},"correlation_ids":["as:up:01FATZDBM2VGCRW537A405259N","gs:conn:01FAT7G51B7H8S9T0QEVGGD3BA","gs:up:host:01FAT7G51H1EMBX5QSFCMJR05S","gs:uplink:01FATZDBD5TRMD7VMF7BMJKDY6","ns:uplink:01FATZDBDK2H1BA0WPZTW3C5B1","rpc:/ttn.lorawan.v3.GsNs/HandleUplink:01FATZDBDK6RVCXGG0J440347E","rpc:/ttn.lorawan.v3.NsAs/HandleUplink:01FATZDBM2EFSJX03FHV7F3E97"],"received_at":"2021-07-17T19:34:40.516171594Z","uplink_message":{"session_key_id":"AXpDcMNiQiGwLWFsBx2pYQ==","f_port":18,"f_cnt":2292,"frm_payload":"BSAUeKBAAgEBAwIC","rx_metadata":[{"gateway_ids":{"gateway_id":"on-the-hill-01","eui":"00800000A000104F"},"timestamp":4101298211,"rssi":-65,"channel_rssi":-65,"snr":10.2,"location":{"latitude":-29.79981320234865,"longitude":30.762821694859166,"source":"SOURCE_REGISTRY"},"uplink_token":"ChwKGgoOb24tdGhlLWhpbGwtMDESCACAAACgABBPEKOw06MPGgwI0OHMhwYQnuz1hgEguJGxw67oBQ==","channel_index":3}],"settings":{"data_rate":{"lora":{"bandwidth":125000,"spreading_factor":7}},"data_rate_index":5,"coding_rate":"4/5","frequency":"867100000","timestamp":4101298211},"received_at":"2021-07-17T19:34:40.307703855Z","consumed_airtime":"0.066816s","version_ids":{"brand_id":"abeeway","model_id":"abeeway-smart-badge","hardware_version":"1.0","firmware_version":"2.1","band_id":"EU_863_870"}}},"qos":0,"retain":false,"_msgid":"cb67353f.d8bfa8"}

Logo

  1. In the “function” node, change the name to “Decoder - Abeeway Tracker” and past the bellow in the “On Message” tab.
let bytes = Buffer.from(msg.payload.uplink_message.frm_payload)

let decoded = context.Decoder(bytes, msg.payload.uplink_message.f_port)
msg.payload.uplink_message.decoded_payload = decoded
return msg

Logo

7. In the “On Start” tab is where we are pasting our “decoder” (replace with you own decoder for other applications, remember this is for Abeeway and only will work with them) , for the Abeeway is the code below and select done and we can “deploy” the flow
abeeway code

Logo

  1. No if we press the button on the “” your test JSON is injected and you date is decoded.

Logo

  1. If you receive an Uplink from you Abeeway tracker it will also be decoded.

  2. The raw data resides in “msg.payload.uplink_message.frm_payload “

Logo

  1. Your decode data resides in “msg.payload.uplink_message.decoded_payload”

Logo

Roadmap

See the open issues for a list of proposed features (and known issues).

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Project Link: https://github.com/JohanScheepers/TTN-Node-Red-Decoder

node-red-decoder_lora's People

Contributors

johanscheepers avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.