Extracting Data from TTN to my Server

Yes, the idea is that if you would want to use the node while it is not within reach of your Gateway, but it can reach mine (or anyone others) Gateway, it can still send its data. And you (and only you) would still be able to retrieve it.
It might not be an issue for you if your nodes don’t move, are always in the same place, but the idea is to build a distributed network eventually covering the whole planet (or at least large parts of it), with not just one person / party / company being responsible for the gateways. So if you need coverage somewhere, you simply can decide to put a gateway there (without having to ask TTN to put it there) and while doing that not only helping yourself but anyone else in that area.

1 Like

Right now, I have CRC_FAIL 100% errors on the Lora gateway.
06

Here is the updated link for inspecting HTTP requests:
https://requestbin.fullcontact.com

Note that Requestbin has been taken offline due to abuse: https://github.com/Runscope/requestbin

https://requestbin.fullcontact.com is hosted on the Dating-Site https://www.fullcontact.com/

Alternative to RequestBin is Request Baskets: https://rbaskets.in/web

In all cases your TTN data goes to a 3rd party

Both Bin and Baskets are on GitHub, so you can install it on your own server

1 Like

Hi,
I would like to know how I could extract specific fields from the JSON received in MQTT please. I’m using this code :

var ttn = require(‘ttn’);
var appId = ‘id’;
var accessKey = ‘mykey’;
ttn.data(appId, accessKey)
.then(function (client) {
client.on(‘uplink’, function (devId, payload) {
console.log(payload)
})
})
.catch(function (error) {
console.error(error)
process.exit(1)
})

and I receive this :

{ app_id: ‘id’,
dev_id: ‘da5a56d070000007’,
hardware_serial: ‘DA5A56D070000007’,
port: 1,
counter: 267,
payload_raw:
<Buffer … >,
payload_fields:
{ analog_in_1: 4,
analog_in_2: 0,
analog_in_3: 59,
digital_in_7: 1,
luminosity_6: 247,
relative_humidity_5: 78.5,
temperature_4: 26.4 },
metadata:
{ time: ‘2019-05-31T03:16:32.248557222Z’,
frequency: 868.1,
modulation: ‘LORA’,
data_rate: ‘SF10BW125’,
airtime: 493568000,
coding_rate: ‘4/5’,
gateways: [ [Object] ] } }

For instance, I would only like to extract the luminosity_6 field please.

Hi @abdelrazak, you can feed the JSON into the jq utility. To extract the luminosity_6 field you could use your existing code and pipe the output into jq and use it to extract only the fields that you want:

your-existing-code | jq ‘.payload_fields.luminosity_6’

Thank you for your answer. I found another method a little earlier by doing this: payload.payload_fields[“luminosity_6”]

But I will see your solution it is perhaps more adapted to my case :slight_smile:

I have a problem here. I wrote a nodeJS snipet that everytime I am sending a specific message to the Gateway I am getting back a timestamp as a downlink message. Which works but I stopped running the nodeJS at my side but I keep receiving this message everytime I am sending something to gateway, no matter the payload… How do I stop it and why this is happening?

Thanks in advance,
Haris