Fetching timestamp from Metadata

Hi,

I have just started working with TTN nodes and I am using arduino with LoRa Shield. I am sending some sensor data to TTN and storing the bulky audio on a SD card. I want to fetch time from TTN so that I can properly timestamp my data on SD card. Since I will be writing every few hours, the accuracy of time stamp is not an issue at all. I can see the time on metadata of packets received from my node, but how can I use the java script to fetch it and send it as data to my node to be used as a time stamp?

{
“time”: “2019-07-10T07:16:05.617777114Z”,
“frequency”: 916.8,
“modulation”: “LORA”,
“data_rate”: “SF7BW125”,
“coding_rate”: “4/5”,
“gateways”: [
{
“gtw_id”: “uwa-crawley”,
“gtw_trusted”: true,
“timestamp”: 3800391379,
“time”: “2019-07-10T07:16:05Z”,
“channel”: 0,
“rssi”: -100,
“snr”: 9.5,
“latitude”: -31.979624,
“longitude”: 115.814224,
“location_source”: “registry”
}
]
}

It is quite a basic question and I spent a lot of time searching for an answer on different forums but didn’t find anything. A little help here will be really appreciated.

Thanks

:partying_face:

can’t you add an RTC module to your arduino to get a time stamp for your SD card writings ?

Hi BoRRoz,

It is definitely an option to use RTC module but I think it will be an overkill just for time-stamping the data. It is going to eat up pins and space on my prototype. I have quite a large number of sensors to interface so I will avoid anything which can be avoided. I will be surprised if there is no possible means to fetch time despite having a connection to TTN.

It’s not quite what you asked for, but should be a pointer even if you’re not using aruino-lmic (mcci-catena in this case, I’ve not looked to see if it’s directly supported on the original code).

Here’s an example of requesting the time from the gateway.

Hi bwooce,

Thanks for sharing the example. I switched the library as mine did not have these functions. I was hopeful that it will work, but unfortunately it didn’t. The problem is here on line 215 of example you shared.

    if (flagSuccess != 1) {
            Serial.println(F("USER CALLBACK: Not a success"));
            return;
        }

The success flag is never 1. The communication with TTN is working without any problem though. I will see if I can ask for help at the github repo.

Any other help in the meanwhile will be appreciated.