Using DevTimeReq to get time on V3

Is anyone here using DevTimeReq to get time from v3 network?
I’m using the code example from MCCI LMIC. It works on v3, i get a time. But the calculated time is always ~18 seconds in the future.

I could not yet figure out, why. Thus, i would like to ask if anyone here can confirm that v3 delivers correct time?

:thinking: Your probably using the wrong value of flux capacitors… :rofl:

Are you accounting for leap seconds? The result is, per spec, seconds after GPS epoch.

GPS epoch was at Jan 5, 1980. There are 18 leap seconds since then. See

You can safely add 18 to the resulting number.

There are currently no future leap seconds announced. As they get announced, you need to update your firmware.


Ok, it’s as simple. Thanks for this hint. I was into leap seconds already, but had 37 secs in mind. But this is since 1972, not 1980, and GPS epoch is 1980.

So, in the code on the node i will subtract (not add!) 18 leap seconds from the time value which is delivered by DeviceTimeAns.

But this leads us to another problem: adding leap seconds “at the edge” on a LORAWAN node sounds like a bad idea. Because with next leap second we need a firmware update on the node. So, why not delivering current time from network?


I agree that unix time is more useful for most end devices. I wasn’t in the LoRa Alliance technical committee when this was decided so I don’t know the background. My guess is twofold: 1) class B beacons use GPS too (directly from the gateway’s GPS) so the time is harmonized and it allows for faster beacon acquisition and verify that the beacon is authentic and not replayed and 2) it’s safer for end devices to not skip seconds (i.e. when counting things over time) than to explicitly skip seconds.

You can always send an application data downlink message whenever there’s a leap second announced and make your firmware aware of that.

1 Like

As they get announced, you need to update your firmware.

Oh no :frowning:
Another decision made by the guys up there that doesn’t understand hardware.

I don’t really understand the problem. I’m happy to bring this in to TC but then I first have to understand why you want the end device to be aware of leap seconds.

If your use case is to show a wall clock, yes, you will need leap seconds. You will also need the timezone though, as well as daylight saving time and future changes to that. This is very much beyond the scope of LoRaWAN.

If your use case is for your end device to be aware of absolute time, which it uses to register events at a certain time, that are then aggregated, logged or transmitted later, it is perfectly fine to use GPS time, right? Your application in the cloud can apply leap seconds. Plus you won’t get weird glitches in the measurements.

Only if your use case is for your end device to do something exactly on top of every hour, then sure, you need to know the leap seconds on the end device. Still, some time zones are +/-hh:15 and +/-hh:30, so you need a side channel to communicate that offset. Also, with firmware or battery life of 10 years, you can expect 4 seconds or so. I really don’t get the issue.


For values of sending a value that gets stored in a variable and/or flash - not a whole firmware update!


Fully agreed.

You could implement programmable offsets in the end node, with offset in seconds and valid-from time. Then set them from a downlink msg. You could update devices before the new leap-second occurs.

Hi All,
I managed to get this example to work with TTN using an RP2040 board.
Now i’m trying it with an M0.
It joins, but i keep getting ‘USER CALLBACK: Not a success’
Has anyone managed to get network time using an M0 board?

The Feather M0 is a first class device for LMIC - ie it’s one of the preferred ones, so this is somewhat surprising.

Are ‘normal’ join & uplinks working OK?

Can you do a manual downlink (just the one)?

Hi Nick, thanks so much for getting back.
A quick question before i dig into what i’m seeing on uplinks/downlinks…
I have both MCCI_Arduino_LoRaWAN_Library and also MCCI_LoraWAN_LMIC_library in my Arduino libraries folder.
The header of the ttn-otaa-network-time example includes <lmic.h>
How can you tell if the Arduino IDE is actually using the LMIC library?

Screenshot 2024-06-01 at 23.06.55
Screenshot 2024-06-01 at 23.07.13

Look at the compile logs to see if it had to make a choice?

But as LMIC is only in the MCCI LoRaWAN LMIC library because RTFM will show you that the Arduino library is a wrapper to simplify the LMIC library, like me, there can be only one.

It works now!
I added #define LMIC_ENABLE_DeviceTimeReq 1 to the lmic_project_config.h and now it works!


RTFM for the win!