Get time with ESP32 T-Beam from ttn v3 with arduino-lmic


It sounds like a simple task, but I have been already looking for some time for a solution how to get time from ttn v3 while using an esp32 ttgo t-beam v1.1. There are so many questions, threads, and comments online, but It seems that I can’t find a simple working example or even a conclusive explanation.

I use

  • ttgo t-beam v1.1

  • gps when outside (where I can get time from gps)

  • ttn v3

  • library: matthijskooijman/arduino-lmic / mcci-catena/arduino-lmic

  • nodes registered with frequency for europe 863-870 MHz SF9 for RX2

  • LoRaWAN version MAC V1.0.3

  • OTAA

  • Class A only

  • can NOT add any new hardware

All I want is just to get the time with +/- some seconds from ttn v3. Is there any working example with DeviceTimeReq / DeviceTimeAns?

I also tryed to send the time as epoch unix timestamp with a downlink, following the uplink, but I am not sure if I will be able to get every needed downlink.

Is there any default (easy) way how to get time from ttn v3? Any method in the arduino-lmic library where one can request the time from a gateway?

any help would be appreciated


How about adding an RTC module to your project. There are fairly cheap ones with a few seconds drift, and some slightly more expensive ones that are more precise. With one of the cheap ones, you could send one time downlink per day to fix any drift.

BTW. It’s not a good idea to use an RTC to set the time of your uplinks. Imagine what would happen if every node on the network decided to send an uplink at exactly the same time on a regular basis. Better to allow a bit of randomness on the timing of uplinks.

I forgot to mention, that I can NOT add any new hardware to the system. I need to solve it with source code. When I am outside and get a gps signal, I can get the time from gps. But without gps signal inside buildings, I would still need the time.

And thx for the reminder. You are right that one should not send an uplink at exactly the same time on a regular basis!