Does RAK7243 support fine timestamps for geolocation?

Hello guys

Maybe I am being redundant, but it is kind of urgent to me to confirm if it is possible somehow to perform geolocation with your RAK7243. I have bought 03 of them, for a thesis project.

Maybe I was wrong by JUST checking the technical specification of the GPS module inside the RAK7243. According to RAK7243 datasheet, the LoRa module is the RAK2243 (which model name is RAK2245) which has a Ublox Max-7Q GPS module, which can provide +/- 60ns accuracy 99% of the times, according to its datasheet.

I have a LoRaWAN network connected to TTN. The RAK7243 is registered as gateway on TTN and it is showing on its packet console the following timestamps:

“timestamp”: “2019-08-13T19:50:55.228Z”,

which I think is a milisecond accuracy timestamp … which is bad for my purposes.

Can you please help me confirming if this is the RAK7243 time accuracy … and therefore not good for developing geolocation applications? I would hate to acknowledge that I made a BIG time mistake by led my analysis based on GPS datasheet accuracy

Thanks

I think the timestamp displayed by ttn is the time that ttn receives the data, not the time that the rak7243’s GPS reads.

Use the following method to view GPS time
1.ssh login to the gateway
2. Use the command “tail -f /var/log/syslog | grep rxpk
3. Until here, the timestamp we see is microseconds

If you want to see nanoseconds, we need to modify the code.

  1. Go to the directory /opt/ttn-gateway/packet_forwarder/lora_pkt_fwd/src
  2. Edit the file lora_pkt_fwd.c and modify the following two places
  3. Go to the directory /opt/ttn-gateway/packet_forwarder
  4. Execute the following command
    1.sudo systemctl stop ttn-gateway
    2.sudo make clean; sudo make
    3.sudo systemctl start ttn-gateway
  5. Use the command “tail -f /var/log/syslog | grep rxpk
1 Like

Hello ZhuQI, thanks for your response.
This is the output of the tail command:

[email protected]:/opt/ttn-gateway/packet_forwarder/lora_pkt_fwd/src $ tail -f /var/log/syslog | grep rxpk
Aug 14 15:58:23 rak-gateway ttn-gateway[18739]: JSON up: {“rxpk”:[{“tmst”:1127511555,“chan”:4,“rfch”:1,“freq”:917.600000,“stat”:1,“modu”:“LORA”,“datr”:“SF7BW125”,“codr”:“4/5”,“lsnr”:10.8,“rssi”:-48,“size”:17,“data”:“QJIsASaA6QABy4zAaIYaiOc=”}]}
Aug 14 15:58:23 rak-gateway ttn-gateway[18739]: JSON up: {“rxpk”:[{“tmst”:1147512547,“chan”:0,“rfch”:0,“freq”:916.800000,“stat”:1,“modu”:“LORA”,“datr”:“SF7BW125”,“codr”:“4/5”,“lsnr”:-6.0,“rssi”:-109,“size”:17,“data”:“QJIsASaA6gABM6WFUk2N5W4=”},{“tmst”:1147512548,“chan”:5,“rfch”:1,“freq”:917.800000,“stat”:1,“modu”:“LORA”,“datr”:“SF7BW125”,“codr”:“4/5”,“lsnr”:10.0,“rssi”:-48,“size”:17,“data”:“QJIsASaA6gABM6WFUk2N5W4=”}]}
Aug 14 15:58:23 rak-gateway ttn-gateway[18739]: JSON up: {“rxpk”:[{“tmst”:1167513539,“chan”:3,“rfch”:0,“freq”:917.400000,“stat”:1,“modu”:“LORA”,“datr”:“SF7BW125”,“codr”:“4/5”,“lsnr”:9.2,“rssi”:-48,“size”:17,“data”:“QJIsASaA6wABsB3GzqbtEy4=”}]}

From what I’ve read [1], the timestamp format from the output is a 10 digit epoch time, which is an integer number. I don’t see the microseconds that you see in your tests. Can you comment please a little bit how is the format that you mentioned:

3. Until here, the timestamp we see is microseconds

Another thing is that on point 2:
2. Edit the file lora_pkt_fwd.c and modify the following two places

Sorry if it is obvious but I don’t know what to change on lora_pkt_fwd.c file

Thanks to all for your help.

References:
[1] https://help.sumologic.com/03Send-Data/Sources/04Reference-Information-for-Sources/Timestamps%2C-Time-Zones%2C-Time-Ranges%2C-and-Date-Formats

If you connect the gps antenna to the gateway and put the gps antenna outdoors, the information you see with the command “tail -f /var/log/syslog | grep rxpk” will contain the following:

=================================================================
Edit the file lora_pkt_fwd.c and modify the following two places,time will be displayed to nanoseconds


1 Like

Hello ZhuQI, many thanks indeed for your response

I got to say that maybe you haven’t check my logs because if so, you would have notice that no “time” label is displayed, which means that a hidden problem is ocurring and I just notice it by examining this issue very deeply.

  • I have check physical GPS antena connection to the RAK and it is Ok (actually on my 03 Raks)
  • I have check the global and local config files on all RAKs to be sure that they are all pointing to /dev/ttyAMA0 logic port. They all are.
  • I have check that /dev/ttyAMA0 has the correct permissions (write and, specially, read permissions are enable on that logic port as you can see below):

[email protected]:~ $ ls -lh /dev/ttyAMA0
crw-rw---- 1 root dialout 204, 64 Aug 15 23:16 /dev/ttyAMA0

I have numbered these items because, when I reset the lora packet forwarder, at some point the output presents the following line:

Aug 15 23:46:10 rak-gateway ttn-gateway[2087]: WARNING: [main] impossible to open /dev/ttyAMA0 for GPS sync (check permissions)

This is why I never received the timestamp, permissions.

I am using the “RAK7243 with LTE OS” downloaded from RAKwireless repository and I always thought that GPS was working fine but I have realized that it has NOT. I also have run the following test which tells me that GPS is fine but, due to the reasons explained before, it is not feeding the SX1301 concentrators timestamps.

[email protected]:/opt/ttn-gateway/lora_gateway/libloragw $ ./test_loragw_gps
Beginning of test for loragw_gps.c
*** Library version information ***
Version: 5.0.1;


~~ UBX NAV-TIMEGPS sentence, triggering synchronization attempt ~~
Synchronization error.
WARNING: [gps] could not get a valid message from GPS (no time)
WARNING: [gps] could not get a valid message from GPS (no time)
WARNING: [gps] could not get a valid message from GPS (no time)
WARNING: [gps] could not get a valid message from GPS (no time)
WARNING: [gps] could not get a valid message from GPS (no time)
WARNING: [gps] could not get a valid message from GPS (no time)
WARNING: [gps] could not get a valid message from GPS (no time)
WARNING: [gps] could not get a valid message from GPS (no time)
WARNING: [gps] could not get a valid message from GPS (no time)

~~ UBX NAV-TIMEGPS sentence, triggering synchronization attempt ~~
* Synchronization successful *
UTC reference time: 1565911952.000000000
GPS reference time: 1249947176.000263865
Internal counter reference value: 12562500
Clock error: 1.000000000
* Test of timestamp counter <-> GPS value conversion *
Test value: 13062500
Conversion to GPS: 1249947176.500263865
Converted back: 13062500 ==> 0µs
* Test of timestamp counter <-> UTC value conversion *
Test value: 13062500
Conversion to UTC: 1565911952.500000000
Converted back: 13062500 ==> 0µs

So the basic question is what is going on with the gps permissions …

The following belongs to the global_conf.json (the part that is regarding the gps, of course):

"gateway_conf": {
	"gateway_ID": "0000000000000000",
	/* change with default server address/ports, or overwrite in local_conf.json */
	"server_address": "router.au.thethings.network",
	"serv_port_up": 1700,
	"serv_port_down": 1700,
	/* adjust the following parameters for your network */
	"keepalive_interval": 10,
	"stat_interval": 30,
	"push_timeout_ms": 100,
	/* forward only valid packets */
	"forward_crc_valid": true,
	"forward_crc_error": false,
	"forward_crc_disabled": false,
	/* gps enable */
	"gps": true,
	"gps_tty_path": "/dev/ttyAMA0",
	"fake_gps": false,
	"ref_latitude": 10,
	"ref_longitude": 20,
	"ref_altitude": -1,
	"autoquit_threshold": 6
}

The following belongs to the local_conf.json
“gateway_conf”: {
“gateway_ID”: “XXXXXXXXXXXXXX”,
“gps”: true,
“gps_tty_path”: “/dev/ttyAMA0”,
“fake_gps”: false
}

Thanks indeed

Using the command tail -f /var/log/syslog | grep ttn-gateway, can you see the following information?

Can you take a picture of your RAK7243 gateway? Shooting angle like the photo below
2019-08-16%2010%3A43%3A32

Hi ZhuQI

Thanks again four your help. I am not at the lab right now, so if necessary I will provide pictures in few hours.

Regarding the output of the GPS on the following command:
tail -f /var/log/syslog | grep ttn-gateway

is as follows:

### [GPS] ###
# GPS sync is disabled
##### END #####

And Yes!, I have setup the LoRa and GPS antennas as depicted on the picture. I checked the guide from the RAKWireless repository.

Hello everyone

Please, consider this thread as solved.
Problem was really weird. At first, following instructions from the guide, GPS was not working, so I decided to go through a Google search to obtain suggestions on how to address the issue. Well, I followed an alternativo guide and I got to change the logic port /dev/i2c… For /dev/ttyAMA0… Well, maybe this works with proper config… But in my case, this was the root of GPS problems.

So, in a nutshell, Just follow the RAK 7243 guide and GPS will work. Even more, from this thread, I Would like to thank ZhuQI for his hint to enable nanoseconds timestamps support.

Thanks.

I will open a other thread to talk about radio gateway synchronization.