Application Data - Payload

Hi,

I would like to request help in the construction of payloads.
Right now I have 2 Gateways in operation - one connected to an internal server and the other to the TTN Console.
The two gatways have 3 sensors sending data. Both have on both servers an application created (on each of them) that receives the data and here is where the problem happens
In an already predefined api (example tagoIO) I receive the data already processed and I can make the graphs I want, but when I want to be the one to receive the data in my application, save it in my database and present the data in my graphs, already I can’t because I don’t know how to work with the payload I receive. Can someone help me? any tutorial to follow to make it all easier?

This is not workable.

Devices can only interact with one network server at a time.

You’ll need to point both gateways at the same server (for this to be on topic, that would have to be TTN), or at least remove the knowledge of the devices from one server.

Technically you could have a second server that knew the secrets “follow along” but it must never attempt to transmit to the nodes - and I don’t know of any lorawan server which has a “never transmit” mode.

That is not my problem. Both are working. The TTN is receiving information from the sensors. My only problem is when I send the information to my database. So I don’t know how to correctly retrieve the information from my payload and this way my database doesn’t have (temperature, humidity, status) and so I can’t create graphics

That is a mistaken conclusion.

You need to switch to using only one server before you worry about anything else.

So I don’t know how to correctly retrieve the information from my payload

Because decrypting and validating payloads depends on sessions state and secrets, the first step is having the nodes in communication with exactly one server, no more, no less.

This is simply how LoRaWAN works.

Ok speaking only on ttn, what is the best way to decrypt the data that comes from my sensors?

If they are registered on TTN and only on TTN, and they properly implement LoRaWAN, then TTN does the decryption for you, because that is one of the key parts of the server’s job.

My first server was ttn and that didn’t happen. I will try this again

If the node is correctly operating with TTN, then the data TTN gives you is exactly some of the cleartext packets payloads which your node puts into its LoRaWAN stack to be encrypted and sent (it won’t be quite all of them - even under the best of circumstances some get lost on the air)

What those payloads mean is a question which at both ends is up to you alone

Perhaps you could show us what arrives on the TTN device console Data tab as a starting point and tell us what sensors you have and tell us what the code is that you use to create the payload on the device …

1 Like

@pedrosantos
What Payload format or Codec are you using to decode the payload on the application?

1 Like

My sensors are:

  1. TBDW100-868 (Door sensor)

  2. KONA All-in-one Home Sensor (Base Variant)

  3. Sentrius RS1xx LoRa

Images of what I get on ttn:

  1. Door Sensor: image

  2. Kona Sensor: image

  3. RS1xx: image

Format:
image

But I already tried 1custom, but I didn’t get along

Do you have the Cayenne LPP library and payload formatting on all of the sensor nodes?

Do you have the documentation that explains the format of the uplink for these three devices?

How are you receiving data from TTN to your server?

What language(s) are you familiar with to write the code to process the uplinks?

Sorry for the delay in the response. Can you explain it better? My Payload Formats is configured with Cayenne LPP, what do I need on the sensors? How do you get settings on the sensors?
Thank you for your help

“Do you have the documentation that explains the format of the uplink for these three devices?”
I have but it’s not that I understand that very well

“How are you receiving data from TTN to your server?”
I send the information via HTTP integration, and I get it with influxDB and I wanted to work with the graphana. But I accept new suggestions

“What language (s) are you familiar with to write the code to process the uplinks?”
Tell me the best chances please

PS: sorry for the delay in replying.

This is a very open ended response so I’m struggling to think how to move you forward.

You could use the JavaScript decoder that you can setup in Payload Formats in the Application console - search the forum for examples. This will then add the fields to your HTTP Integration that could be picked up by influxDB.

Choice of programming language is often best guided by the context in which it is going to run, and the availability of examples which could be adapted from accomplishing the same basic task for slightly different data, to accomplishing the task for needed data.

The javascript decoders running within TTN have historically had some reliability problems, but they the one place you can insert something without having to create a new sort of context in which it can run.

To use something else (python, java, even javascript running under node) you’d need to get or push the data from TTN into a place where the custom software runs, and from there push into influx, rather than do so directly. For example you might get the data by having a task on a server subscribe to the MQTT feed, decode it, then push records of parsed fields into influx.

While you could store raw still-concatenated payloads in influx, you won’t really get the benefit of a time series database with an arbitrary chunk of bytes, but only if you’ve already broken the data items into individual fields whose change over time is distinctly visible before you insert them.

You also want to make sure you’re capturing metadata such as timestamp and frame count; spreading factor and gateway/RSSI pairs can be useful too to understand changes in coverage and reliability over time.

The payload must be encoded from the sensor and then You must have the payload decoded on the application server. And for that you will need the Cayenne LPP library installed on the nodes, if you use Arduino IDE, it’s easy.
Are the sensor nodes self built? Or did you buy them?

All the best

For instance, I have the Cayenne LPP(low power packet) library on my sensor node to encode the payload for the My devices dashboard.
Then, from the Application server, I have the Payload Codex/ Payload Formatting set to Cayenne LPP. From the server it then forwards payload to Cayenne MQTT broker, which ads it automatically to the My devices dashboard after Device has been added with correct credentials.
Works really great. Even have the same data relayed onto the Adafruit IO dashboard.