How to get the timestamp associated with the LoRa message?


(Silas Valera) #1

Hi

Instead of sending out the actual time from the end device as part of payload, I would like to use the time stamp associated with the LoRa message received by TTN. This will reduce the payload size and I can accommodate more useful data there. What is the best way to fetch the timestamp in the payload decoder function? I can then send the time as part of Jason message.

Thank you so much for the help!
Best
Silas


(Arjan) #2

In a Payload Format in TTN Console you can only use the port and the application payload. So, you cannot access any of the metadata. You could add the current server time:

var now = new Date().toISOString();

However, it doesn’t add much that whatever is processing the JSON cannot easily add itself.

See also Access Metadata in decoder.


(Afremont) #3

If you use an mqtt connection to the backend, you can see all the metadata information in json format. The nice thing about it is that you get the messages in real-time. I currently use node red to do this, it works great. You can see the gateway(s) that received the message and everything they provide, such as gps location, RSSI, SNR, channel, frequency, spreading factor, coding rate etc.

I have a dashboard user interface that shows me these things with gauges and charts. When I start capturing real data, I will be inserting the data into a local MySQL (or sqlite) database. Grafana (sp?) is another way to view historical data in a pretty web interface.

Andreas Spiess offers a ready made image for a raspberry pi that includes most of the software I mentioned above. It’s a good starting point for an iot data warehouse. It uses influxdb as the database manager, which has its own unique benefits.


(Jeff Uk) #4

Link? :wink:


(Silas Valera) #5

@arjanvanb & @Afremont
Thank you so much for your replies!!

@Afremont I would really love to setup IOT data warehouse since I will have many field devices. Would you please provide more info? I would like to set up a Ubuntu server online which would receive all the field devices information and store data for trending, and an application layer which can allow for charts/graphs. I am considering LoRaServer for now. But would be very much interested your setup…

Thanks again :slight_smile:


(Ud Lo Ra) #6

LoraServer is an alternative to TTN, so solutions proposed here cannot be directly applicable (though something similar is surely available).
Anyway, also HTTP Integration here on TTN makes metadata available (easy way of connecting to some web-based application).


(Afremont) #7

This is Andreas Spiess’ video about using the Raspberry Pi image containing Node-Red, InfluxDB, and Grafana.

I started down a different path using a Raspberry Pi by setting things up the hard way. I didn’t know about InfluxDB at the time, nor anything about Grafana. I like what they have to offer vs MySQL and the node red dashboard, so I may start over with my project.


(Silas Valera) #8

@UdLoRa I am considering to setup my private LoRa network for my devices, and LoRaServer seem to have the communication to devices part and also the application to manage devices. But the data presentation not available. For now I have the following setup - EndDevices -> TTN -> UbiDots -> Data presenation. But I would like to have all these in one place…

@Afremont Thanks for the video link !! Very interesting!


(Ud Lo Ra) #9

I understood, but if you ask here how to get the timestamp, you will receive the TTN version of the answer, not necessarily identical to the one needed for LoraServer :wink:


(Silas Valera) #10

@UdLoRa
That is true :slight_smile: So I asked for payload decoder in TTN. And the answer will be helpful for my current implementation :slight_smile:
Thanks again