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.

I have the same problem. Any known solution to this problem?

USER CALLBACK: Not a success, flagSucccess is 0

4507513: setupRx1 txrxFlags 0x20 → 01
start single rx: now-rxtime: 3
14508145: RXMODE_SINGLE, freq=867500000, SF=7, BW=125, CR=4/5, IH=0
rxtimeout: entry: 14508996 rxtime: 14508138 entry-rxtime: 858 now-entry: 5 rxtime-txend: 312375
14570013: setupRx2 txrxFlags 0x1 → 02
start single rx: now-rxtime: 4
14570645: RXMODE_SINGLE, freq=869525000, SF=9, BW=125, CR=4/5, IH=0
rxtimeout: entry: 14572453 rxtime: 14570638 entry-rxtime: 1815 now-entry: 3 rxtime-txend: 374875
14572470: processRx2DnData txrxFlags 0x2 → 00
14572562: processDnData_norx txrxFlags 00 → 20
14572833: EV_TXCOMPLETE (includes waiting for RX windows)
14573154: engineUpdate, opmode=0x900
USER CALLBACK: Not a success, flagSucccess is 0