QUESTION: Is remote time synchronization possible with the MeteoHelix LoRaWAN weather stations on TTN so that they can send data in 10 minute intervals on the hour?
ANSWER: MeteoHelix weather stations provide the ability to change settings and time synchronization remotely via a LoRaWAN down link connection from The Things Network (TTN) and other LoRa server providers. The below instructions and screenshots will guide you through the setup process.
Time Synch on TTN
Log into your The Things Network Console at the following link: https://console.thethingsnetwork.org/
TTN Console quick downlink instructions
In the top horizontal menu, click Applications.
Select the application which contains your device as shown in the screenshots.
In the lower horizontal menu, select Devices.
Next, select the device requiring time synchronization.
In the new lower horizontal menu, select Overview.
Scroll way down to find the Downlink section.
To send the time synchronization, fill out the Downlink section as follows:
Scheduling = “replace” or “first”
FPort = 1
Payload = 01 5B E7 03 D0 00 00 00
Confirmed = checked or unchecked
Detailed downlink format explanation
Scheduling is set by default to “replace”, thus replacing all currently scheduled downlinks, if any, so that any other previously scheduled downlinks will not be sent. Setting the downlink scheduling to “first” or “last” will put this manually added downlink message in the downlink queue ahead of or after the already scheduled downlinks.
FPort for 99% of use cases will remain set to 1.
Payload format is 8 bytes long. Each pair of symbols is a byte in hexadecimal format as follows:
01 5B E7 03 D0 00 00 00
The first byte (first pair) identifies the type of message being sent. For time-synch command, the first pair must be 01. (In hexadecimal syntax 0x01)
01 5B E7 03 D0 00 00 00
The next four bytes (four pairs) contain the Unix Epoch time stamp in hex number format, 5DE703D0, which converts to 1575420880 in our familiar decimal system and in Unix Epoch time to: GMT: Wednesday, December 4, 2019 00:54:40
01 5B E7 03 D0 00 00 00
The last three bytes ( 3 pairs) are empty (zeros).
The current Unix epoch time in seconds in hex format can be found here: https://www.epochconverter.com/hex
The current Unix epoch time in seconds in decimal format can be found here: http://easyonlineconverter.com/converters/epoch_converter.html
Confirmed may be left unchecked for MeteoHelix weather stations.
Preparing time-synch downlink payload
If the last received data arrives at 20:19:47, 13 seconds too early, the internal time of the weather station is 13 seconds ahead of official GMT time. Since data is set by default to 10 minute intervals, we will send the weather station the last received time plus 10:00 minutes, since the downlink data on LoRa devices can only be received in a short window of time right after the device uploads its sensor data.
Converting date and time to downling message hexadecimal format
|Your input: |
(Date & time of last recieved data +
|Converted to Unix epoch |
decimal date and time
|Decimal epoch date and time||Converted to hex epoch date and time|
Add 10 minutes to the last recived data time stamp 20:19:47 + 10 minutes = 20:29:47
Convert time “YYYYMMDD 20:29:47” to Unix Epoch time stamp to Unix ten digit decimal format: Date & time to Unix Epoch decimal format converter
Convert the decimal time stamp to four byte hexadecimal format for insertion into the time-sych message: Decimal-to-hex converter
Creating the downling message hexadecimal format
Time-synch command is 0x01 in hex format: 01
Append the four byte hex date and time after the 01 command: 01 5C B0 F2 E3
Append three empty bytes (00 00 00) so the total message length is 8 bytes: 01 5C B0 F2 E3 00 00 00
Advanced information on how to setup automatic downlinks using your application as connected to the TTN LoRa server can be found here: https://www.thethingsnetwork.org/docs/applications/mqtt/api.html#downlink-messages
How does the MeteoHelix automatically handle time synchronization?
All that is required is for the MeteoHelix IoT Pro to recieve a Unix time stamp of the last received data in the form of the above specified 0x01 hex command. It then performs time synchronization according to an internal algorithm which also prevents the duplicate sending of messages after time synchronization has been performed.
The internal real time clock is very accurate and only drifts a few seconds per week. Thus, time synchronization should only be required every few weeks to maintain accurate data uplink intervals, unless environmental temperatures are highly variable.
If time time on device is sent forward and skips over the 10min sending internal time ( 29:36 -> 30:05) than the data from the last 9:36 will be averaged together with the next 10min interval data and be sent at 40:00 time.
Recieve window 1 length
Receive window 2 length
Acknowledge (Ack) timeout is set to 2 seconds. Modem resets if Ack timeout (message 2D) is received.