IoT devices don't naturally have a notion of time yet they need time for a variety of reasons including time stamping of sensor measurements. Local knowledge of global time is also essential for blockchain communications.
There are a few ways to get time onto devices in the field - mostly dependent on communication devices. GPS is a good way to get time but if your product has no GPS and just LoRaWAN, how do you get time transferred? There is MAC-layer support for transferring time to devices, however this is not universally supported on the network side, nor supported on popular LoRaWAN networks like Helium. We've implemented an IoT time transfer scheme over LoRaWAN at the application layer and this works with Helium (and any other LoRaWAN network).
Our solution achieves millisecond accuracy for time transfer using Helium networks (relative to the time of the receiving gateway) by this method:
1. Sending a request to our application server using our open source Measurement Earth Low Power Protocol with a request ID (incrementing counter).
2. Recoding the device's internal time at the time of the LoRaWAN radio's TxComplete interrupt after transmitting that request. This will align very closely to the Helium hotspot/gateway's 'reported_at' time. We record the request ID and local internal time into a circular queue with some depth to handle delays and missed downlinks.
3. On the server, receive the HTTP POST and JSON from Helium, recording the time request ID and the gateway's 'reported_at' time, then forwarding a downlink with this request ID and gateway time back to the device.
4. On the device's next uplink, it may receive this queued downlink. Upon doing so, it looks up the request ID in the local time request queue to find the matching local timestamp. The actual time is computed as the downlink's gateway 'reported_at' time plus the difference between the current device time and the timestamp aligned with TxComplete interrupt, which aligns with the gateway's Rx time.
We've implemented a reference design of this concept in a server for forwarding sensor measurement transactions to the AntelopeIO blockchain in our open source protocol engine.