898 views|2 replies

119

Posts

1

Resources
The OP
 

[Digi-Key Follow me Issue 1] -4- Realizing the positioning function [Copy link]

 This post was last edited by Murong Xuehua on 2023-6-6 11:28

1. Basic introduction of Air530 positioning module

This GPS module is the main reason why I participated in this FOLLOW-ME event. The GPS module used this time is Air530 launched by Seeed, which not only supports GPS, but also China's Beidou, including: GPS / Beidou / Glonass / Galileo / QZSS / SBAS.

The relevant parameters are as follows:

  • Supply voltage 3.3V/5V
  • Working current up to 60mA
  • Interface UART
  • Time of warm start 4s
  • Time of cold boot 30s

The module has 4 pins, namely:

GND Grounding
TX Serial port sending
RX Serial port receiving
VCC power supply

Hardware connection diagram:

2. GPS Data Analysis

The following is the core of this article, which is mainly about how to parse the positioning information from the received data.

In fact, by reading UART data, you can find that there are many formats of satellite data that can be obtained.

$GNGGA: GPS/Beidou positioning information

$GNGSA: Current satellite information

$GPGSV: Visible GPS satellite information

$BDGSV: Visible Beidou satellite information

$GNRMC: Recommended positioning information

$GNVTG: Ground speed information

$GNGLL: Geodetic coordinate information

$GNZDA: Current time UTC (1) information

This article selects one of them: GNGLL.

$GNGLL,<1>,<2>,<3>,<4>,<5>,<6>,<7>*<8><CR><LF>
<1>Latitude ddmm.mmmm, degree-minute format (if the leading digit is insufficient, fill in 0)
<2>Latitude N (North Latitude) or S (South Latitude)
<3>Longitude dddmm.mmmm, degree-minute format (if the leading digit is insufficient, fill in 0)
<4>Longitude E (East Longitude) or W (West Longitude)
<5>UTC time, hhmmss.sss format
<6>Status, A=positioning, V=unpositioned
<7>Mode indication, A-automatic mode; D-differential mode; E-estimate (dead reckoning) mode; M-manual
input mode; S-simulator mode
< 8>Checksum

The main code is as follows:

def getGPS(gpsModule):
    global FIX_STATUS, TIMEOUT, latitude, longitude, satellites, GPStime
    
    timeout = time.time() + 8 
    while True:
        gpsModule.readline()
        buff = str(gpsModule.readline())
        parts = buff.split(',')
        print(buff)
    
        if (parts[0] == "b'$GNGLL" and len(parts) == 8):
            if(parts[1] and parts[2] and parts[3] and parts[4] and parts[5] and parts[6] and parts[7]):
                print(buff)
                
                latitude = convertToDegree(parts[1])
                if (parts[2] == 'S'):
                    latitude = -latitude
                longitude = convertToDegree(parts[3])
                if (parts[4] == 'W'):
                    longitude = -longitude
                #satellites = parts[7]
                GPStime = str((int(parts[5][0:2])+8)%24) + ":" + parts[5][2:4] + ":" + parts[5][4:6]
                FIX_STATUS = True
                break
                
        if (time.time() > timeout):
            TIMEOUT = True
            break
        utime.sleep_ms(500)
        
def convertToDegree(RawDegrees):
    RawAsFloat = float(RawDegrees)
    firstdigits = int(RawAsFloat/100) 
    nexttwodigits = RawAsFloat - float(firstdigits*100) 
    
    Converted = float(firstdigits + nexttwodigits/60.0)
    Converted = '{0:.6f}'.format(Converted) 
    return str(Converted)

The console output is as follows. It can be seen that after obtaining valid GNGLL data, the program correctly parses the precision and latitude.

----------------------
mytime is: 2023-06-06 Tues 09:09:44
mytime is: 2023-06-06 Tues 09:09:45
mytime is: 2023-06-06 Tues 09:09:46
mytime is: 2023-06-06 Tues 09:09:47
mytime is: 2023-06-06 Tues 09:09:48
b'$GNGSA,A,3,06,08,09,16,24,39,,,,,,,3.7,2.1,3.0,4*3C\r\n'
b'$GNGLL,3168.46110,N,12176.26956,E,010943.000,A,A*49\r\n'
b'$GNGLL,3418.46110,N,12156.26956,E,010943.000,A,A*49\r\n'
Printing GPS data...
 
Latitude: 33.307686
Longitude: 123.437828
Satellites: 
Time: 9:09:43
----------------------

This post is from DigiKey Technology Zone

Latest reply

It seems that the premise of correctly parsing out the precision and latitude is to obtain valid GNGLL data.   Details Published on 2023-6-7 07:31
 
 

6593

Posts

0

Resources
2
 

It seems that the premise of correctly parsing out the precision and latitude is to obtain valid GNGLL data.

This post is from DigiKey Technology Zone
 
 
 

119

Posts

1

Resources
3
 
Jacktang posted on 2023-6-7 07:31 It seems that the premise of correctly parsing out the precision and latitude is to obtain valid GNGLL data,,

I only chose a relatively simple GNGLL. There are many other formats available. You can check which format has a better signal on the console first.

$GPGGA Global Positioning System Fix Data. It provides 3D location and accuracy data
$GPGSA It provides GPS DOP and active satellites
$GPGSV It provides the detailed information of the GPS satellite
$GPGLL It provides the geographic Latitude and Longitude
$GPRMC It provides the position, velocity and time
$GPVTG It provides the dual ground/water speed

for example:

$GPGGA, 103005, 3807.038, N, 07128.99030, E, 1, 07, 1.43, 134.5, M, 42.9, M, , *7

  • $: This indicates the start of the NMEA sentence
  • GPGGA: Global Positioning System Fix Data
  • 103005: This is the UTC time when the data was accessed in HH:MM:SS. In this case the time is 10:30:05 UTC
  • 3807.038, N: Latitude 38 degrees 07.038′ N
  • 07128.99030, E: Longitude 71 degrees 28.00030′ E
  • 1: GPS fix
  • 07: Number of satellites being tracked
  • 1.43: Horizontal dilution of position
  • 134.5, M: This shows the altitude (m) above the sea level
  • 42.9, M: Height of geoid (mean sea level)
  • Empty field: time in seconds since last DGPS update
  • Empty field: DGPS station ID number
  • *78: the checksum data
This post is from DigiKey Technology Zone
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list