Time synchronization setup of a MeteoHelix LoRaWAN weather station on TTN
/This article applies to MeteoHelix weather stations made up to 2019 with serial numbers composed only of numbers (no letters). Newer versions of our LoRaWAN sensors (December 2020+) offer the following downlink commands: List of available LoRaWAN downlink commnands
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:4001 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 minutes 11 seconds (10:11), 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 + 10 minutes) | Converted to Unix epoch decimal date and time |
---|---|
20190412 20:19:47 | 1555100387 |
Decimal epoch date and time | Converted to hex epoch date and time |
---|---|
1555100387 | 5CB0F2E3 |
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 downlink scheduling on TTN
Advanced information on how to setup automatic downlinks using your application as connected to the TTN LoRa server can be found here:
TTN API Reference https://www.thethingsnetwork.org/docs/applications/mqtt/api.html#downlink-messages
How does the MeteoHelix automatically handle time synchronization?
Details on how the time synchronization command works to update the current time inside the MeteoHelix can be found in this FAQ thread: