Table of Contents:

1. Introduction


It is possible to GPS supports in LG308N-EC25 version and LPS8v2-EC25 version so device will add location info to uplink packet to LoRaWAN server.

2. Connect GPS Antenna to Cellular modules

Connect GNSS port to GPS antenna. The connector type is i-pex connector, please make sure the GPS antenna can be extended outdoor for GPS signal.

For LPS8v2:

image-20231208153214-1.png

For LG308N:

image-20220527160148-2.png

3. Use Cellular Module GPS feature for LoRaWAN Timing.

3.1 Configure on LG308N / LPS8N

 

Below are the steps:

1. Open the box and connect GPS antenna to GNSS port of EC25

2. modify the two files:

/etc/chatscripts/3g.chat

ABORT   BUSY
ABORT   'NO CARRIER'
ABORT   ERROR
REPORT  CONNECT
TIMEOUT 10
""      "AT&F"
OK      "ATE1"
OK  "AT+QGPS=1"   --> Add this line, so EC25 module GPS will be enable when dial up
OK      'AT+CGDCONT=1,"IP","$USE_APN"'
SAY     "Calling UMTS/GPRS"
TIMEOUT 30
OK      "ATD$DIALNUMBER"
CONNECT ' '

Note: After above settings, the GPS will be enable when dial up, if user doesn't use Cellular for Internet access, above script won't execute, in this case, user can run "echo AT+QGPS=1 > /dev/ttyUSB2" to enable GPS /usr/bin/generate-config.sh, after configure this, in the web page, select any frequency band and save to make this take affect.

gen_gw_cfg() {
   json_init
   json_add_object gateway_conf
   json_add_string "gateway_ID" "$gwid"
   json_add_string "server_address" "$server"
   json_add_int "serv_port_up" "$upp"
   json_add_int "serv_port_down" "$dpp"
   json_add_int "stat_interval" "$stat"
   json_add_boolean "forward_crc_valid" 1
   json_add_boolean "forward_crc_error" 0

   json_add_string "gps_tty_path" "/dev/ttyUSB1"   -----> Add this line so lora program knows to get the gps info from EC25

   json_close_object
   json_dump  > /etc/lora/local_conf.json

}

3. Reboot the device and run logread -f to verify if GPS already works.

Fri Mar  6 04:08:59 2020 daemon.info lora_pkt_fwd[3016]: INFO~ GPS serial port path is configured to "/dev/ttyUSB1"
Fri Mar  6 04:08:59 2020 daemon.info lora_pkt_fwd[3016]: INFO~ [main] TTY port /dev/ttyUSB1 open for GPS synchronization
Fri Mar  6 04:09:00 2020 cron.err crond[1689]: time disparity of 4301528 minutes detected
Fri Mar  6 04:09:00 2020 daemon.info lora_pkt_fwd[3016]: INFO~ sockfd=4
Fri Mar  6 04:09:00 2020 daemon.info lora_pkt_fwd[3016]: INFO~ sockfd=5
Fri Mar  6 04:09:00 2020 daemon.info lora_pkt_fwd[3016]: INFO~ FPort Filter: 0
Fri Mar  6 04:09:00 2020 daemon.info lora_pkt_fwd[3016]: INFO~ DevAddrMask: 0x0
Fri Mar  6 04:09:34 2020 daemon.info lora_pkt_fwd[3016]: INFO: [jit] queue is empty
Fri Mar  6 04:09:34 2020 daemon.info lora_pkt_fwd[3016]: STAT~ {"stat":{"time":"2020-03-06 04:09:34 UTC","lati":22.70627,"long":114.24277,"alti":58,
"rxnb":0,"rxok":0,"rxfw":0,"ackr":0.0,"dwnb":0,"txnb":0}}
Fri Mar  6 04:09:35 2020 daemon.info lora_pkt_fwd[3016]: INFO~ [up] PUSH_ACK received in 293 ms
Fri Mar  6 04:09:35 2020 daemon.info lora_pkt_fwd[3016]: INFO~ [down] PULL_ACK received in 596 ms

3.2. Configure on LPS8v2

 

Below are the steps:

1. Open the box and connect GPS antenna to GNSS port of EC25

2. modify the two files:

/etc/rc.local 

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

echo 0 > /sys/class/leds/dragino\:blue\:opt/brightness
echo 0 > /sys/class/leds/dragino\:green\:stat/brightness
echo 0 > /sys/class/leds/dragino\:red\:sys/brightness
echo AT+QGPS=1 > /dev/ttyUSB2

exit 0

Note:  After above settings, LPS8v2 will enable GPS automatically on boot.

The user can run "echo AT+QGPS=1 > /dev/ttyUSB2" to manually enable GPS.

/usr/local/dragino/generate-config.sh, after configuring this, on the web page, select any frequency band and save to make this take effect.

gen_gw_cfg() {
        json_init
        json_add_object gateway_conf
                json_add_string "platform" "SX1$chip"
                json_add_string "description" "Dragino LoRaWAN Gateway"
                json_add_string "gateway_ID" "$gwid"
                json_add_boolean "radiostream_enable" 1
                json_add_string "ghost_host" "localhost"
                json_add_string "ghost_port" "1760"
                json_add_boolean "manage_enable" 0
                json_add_boolean "custom_downlink" 0
                json_add_int    "stat_interval" "30"
                json_add_boolean "wd_enable" 1
                json_add_boolean "mac_decode" 0
                json_add_boolean "mac2file" 0
                json_add_boolean "mac2db" 0
                json_add_string "log_mask" "1111"
       json_add_string "gps_tty_path" "/dev/ttyUSB1"   -----> Add this line so lora program knows to get the gps info from EC25
                json_add_double "ref_latitude" "$latitude"
                json_add_double "ref_longitude" "$longitude"
                json_add_double "ref_altitude" "$altitude"
                json_add_int "beacon_period" "0"
                json_add_int "beacon_freq_hz" "869525000"

3. Reboot the device and run journalctl -u draginofwd -f to verify if GPS already works.

image-20231208160114-2.png

image-20231208161058-5.png

4. Use Cellular Module GPS feature for System Timing.

4.1 Configure on LPS8v2

This introduction shows how to use the Cellular Module GPS feature for System Timing.

1. Download script from dragino site and move it to properly directory

root@dragino-e4e891:# wget http://repo.dragino.com/release/tool/gpstime/gpstodate.sh
2023-12-21 07:25:25  http://repo.dragino.com/release/tool/gpstime/gpstodate.sh
Resolving repo.dragino.com (repo.dragino.com)... 47.89.8.92
Connecting to repo.dragino.com (repo.dragino.com)|47.89.8.92|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1114 (1.1K) [application/octet-stream]
Saving to: ‘gpstodate.sh’

gpstodate.sh                                      100%[===========================================================================================================>]   1.09K  .-KB/s    in 0s      

2023-12-21 07:25:25 (16.5 MB/s) - ‘gpstodate.sh’ saved [1114/1114]

root@dragino-e4e891:# chmod +x gpstodate.sh;mv gpstodate.sh /usr/bin/
root@dragino-e4e891:#

2. Run cat /dev/ttyUSB1 to check if the GPS location is successful.

image-20231221153129-1.png

3. Run the date and  /usr/bin/gpstodate.sh & to check if the system time is correct

4. Add gpstodate.sh to cron work /etc/rc.local , LPS8v2 will Use Cellular Module GPS feature for System Timing automatically on boot

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

echo 0 > /sys/class/leds/dragino\:blue\:opt/brightness
echo 0 > /sys/class/leds/dragino\:green\:stat/brightness
echo 0 > /sys/class/leds/dragino\:red\:sys/brightness
echo AT+QGPS=1 > /dev/ttyUSB2
/usr/bin/gpstodate.sh

exit 0

5. Use external GPS module

5.1 Set up for LoRaWAN Time

5.2 Set up for System Time