DEV Community

Cover image for QuecPython + GNSS: Implement Fast Positioning
QuecPython
QuecPython

Posted on

QuecPython + GNSS: Implement Fast Positioning

Overview

QuecPython, combined with a GNSS (Global Navigation Satellite System) module, provides an out-of-the-box positioning capability solution for IoT devices. This solution supports multi-constellation joint positioning including GPS, BeiDou, GLONASS and Galileo, and delivers a full-stack positioning solution from hardware access to cloud services for IoT developers.

Advantages and Features

Multi-mode Positioning: Supports GNSS, LBS and Wi-Fi positioning functions
Minimalist Development: Highly encapsulated API interfaces, no need to write underlying drivers

Functional Overview

This article mainly describes how to use the built-in GNSS function of the QuecPython development board to obtain positioning information. The typical programming workflow is divided into the following parts:

  1. GNSS Initialization
  2. Positioning Data Acquisition

GNSS Initialization

This method is used to initialize the function of the module's built-in GNSS module.

quecgnss.init()

For API details, please refer to quecgnss.init.

Positioning Data Acquisition

This method is used to read GNSS positioning data.

quecgnss.read(size)

For API details, please refer to quecgnss.read.

Parameter Configuration

This method is used to set GNSS parameters, including satellite constellation, NMEA sentence type, whether to enable AGNSS and APFLASH, etc.

quecgnss.configSet(config_type, config_value)

For API details, please refer to quecgnss.configSet.

Sample Code

import quecgnss

Initialization

quecgnss.init()

Read data

data = quecgnss.read(4096)

Print data

print(data[1].decode())

Operation Result

The following is an example of the operation result, which mainly introduces the content of the positioning data.

Operation Result

167,169,170,,,,,,,,1.773,1.013,1.455*15

$GPGSV,2,1,8,3,23,303,34,16,32,219,28,22,74,98,26,25,16,43,25*77

$GPGSV,2,2,8,26,70,236,28,31,59,12,38,32,55,127,34,4,5,,21*49

$BDGSV,2,1,8,163,51,192,32,166,70,11,31,167,52,197,32,169,59,334,31*61

$BDGSV,2,2,8,170,40,205,31,161,5,,31,164,5,,27,165,5,,29*59

$GNRMC,022326.000,A,3149.324624,N,11706.921702,E,0.000,261.541,180222,,E,A*38

$GNGGA,022326.000,3149.324624,N,11706.921702,E,1,12,1.013,-8.580,M,0,M,,*47

$GNGLL,3149.324624,N,11706.921702,E,022326.000,A,A*44

$GNGSA,A,3,31,32,3,16,22,25,26,,,,,,1.773,1.013,1.455*1C

$GNGSA,A,3,163,166,167,169,170,,,,,,,,1.773,1.013,1.455*15

$GPGSV,2,1,8,3,23,303,34,16,32,219,27,22,74,98,26,25,16,43,25*78

$GPGSV,2,2,8,26,70,236,28,31,59,12,37,32,55,127,34,4,5,,20*47

$BDGSV,2,1,8,163,51,192,32,166,70,11,31,167,52,197,32,169,59,334,31*61

$BDGSV,2,2,8,170,40,205,31,161,5,,31,164,5,,27,165,5,,29*59

$GNRMC,022327.000,A,3149.324611,N,11706.921713,E,0.000,261.541,180222,,E,A*3F

$GNGGA,022327.000,3149.324611,N,11706.921713,E,1,12,1.013,-8.577,M,0,M,,*48

$GNGLL,3149.324611,N,11706.921713,E,022327.000,A,A*43

...... # More data omitted

$GNGSA,A,3,31,32,3,16,22,25,26,,,,,,1.837,1.120,1.456*11

$GNGSA,A,3,163,166,167,169,170,,,,,,,,1.837,1.120,1.456*18

$GPGSV,2,1,8,3,23,302,27,16,32,220,26,22,73,101,27,25,16,43,27*45

$GPGSV,2,2,8,26,70,237,28,31,59,13,33,32,54,128,28,4,5,,24*44

$BDGSV,2,1,8,163,51,192,33,166,71,11,35,167,52,198,33,169,59,334,34*6E

$BDGSV,2,2,8,170,40,205,32,161,5,,33,164,5,,28,165,5,,30*5F

$GNRMC,022507.000,A,3149.324768,N,11706.922344,E,0.000,261.541,180222,,E,A*31

$GNGGA,022507.000,3149.324768,N,11706.922344,E,1,12,1.120,-8.794,M,0,M,,*48

$GNGLL,3149.324768,N,11706.922344,E,022507.000,A,A*4D

$GNGSA,A,3,31,32,3,16,22,25,26,,,,,,1.837,1.120,1.455*12

$GNGSA,A,3,163,166,167,169,170,,,,,,,,1.837,1.120,1.455*1B

$GPGSV,2,1,8,3,23,302,26,16,32,220,26,22,73,101,27,25,16,43,26*45

$GPGSV,2,2,8,26,70,237,28,31,59,13,32,32,54,128,28,4,5,,24*45

$BDGSV,2,1,8,163,51,192,24,166,71,11,35,167,52,198,33,169,59,334,34*68

$BDGSV,2,2,8,170,40,205,31,161,5,,33,164,5,,28,165,5,,30*5C

$GNRMC,022508.000,A,3149.324754,N,11706.922338,E,0.002,261.541,180222,,E,A*38

$GNGGA,022508.000,3149.324754,N,11706.922338,E,1,12,1.120,-8.750,M,0,M,,*4B

$GNGLL,3149.324754,N,11706.922338,E,022508.000,A,A*46

$GNGSA,A,3,31,3

Data Introduction

NMEA Port Data Classification:

$GPGGA Global Positioning System Fix Data

$GPGSA GNSS DOP and Active Satellites

$GPGSV GNSS Satellites in View

$GPRMC Recommended Minimum Specific GNSS Data

$GPVTG Course Over Ground and Ground Speed

$GPDTM Datum Reference

$GPGNS GNSS Fix Data

NMEA Sentence Parsing:

Basic format of the GSV sentence:

$GPGSV,(1),(2),(3),(4),(5),(6),(7),...,(4),(5),(6),(7)*hh(CR)(LF)

Field 1: Total number of GSV sentences

Field 2: Sequence number of this GSV sentence

Field 3: Total number of visible satellites (00~12, leading 0 will be transmitted)

Field 4: Satellite PRN number (01~32, leading 0 will be transmitted)

Field 5: Satellite elevation (00~90 degrees, leading 0 will be transmitted)

Field 6: Satellite azimuth (000~359 degrees, leading 0 will be transmitted)

Field 7: Signal-to-Noise Ratio (00~99dB, empty when no satellite is tracked) (commonly known as CN value)

Basic format of the GGA sentence:

$GPGGA,(1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12)*hh(CR)(LF)

Field 1: UTC time, in hhmmss.sss format (hours, minutes and seconds)

Field 2: Latitude, in ddmm.mmmm format (degrees and minutes, padded with 0 if leading digits are insufficient)

Field 3: Latitude hemisphere, N (North) or S (South)

Field 4: Longitude, in dddmm.mmmm format (degrees and minutes, padded with 0 if leading digits are insufficient)

Field 5: Longitude hemisphere, E (East) or W (West)

Field 6: GPS status, 0=No fix, 1=Non-differential fix, 2=Differential fix, 3=Invalid PPS, 6=Estimating

Field 7: Number of satellites in use (00 - 12, padded with 0 if leading digits are insufficient)

Field 8: HDOP (Horizontal Dilution of Precision) (0.5 - 99.9)

Field 9: Altitude above mean sea level (-9999.9 - 99999.9)

Field 10: Unit of altitude, meters

Field 11: Geoidal separation (Height of the geoid above the WGS84 ellipsoid)

Field 12: Unit of geoidal separation, meters

Basic format of the GSA sentence:

$GPGSA,(1),(2),(3),(3),,,,,,,,,,(3),(4),(5),(6),(7)*hh(CR)(LF)

Field 1: Positioning mode, A=Automatic 2D/3D, M=Manual 2D/3D

Field 2: Fix type, 1=No fix, 2=2D fix, 3=3D fix

Field 3: PRN (Pseudo Random Noise) code of the satellite in use (up to 12 entries, padded with 0 if leading digits are insufficient)

Field 4: PDOP (Position Dilution of Precision) (0.0 - 500.0)

Field 5: HDOP (Horizontal Dilution of Precision) (0.0 - 500.0)

Field 6: VDOP (Vertical Dilution of Precision) (0.0 - 500.0)

Field 7: Satellite system ID

Basic format of the VTG sentence:

$GPVTG,(1),(2),(3),(4),(5),(6),(7),(8),(9)*hh(CR)(LF)

Field 1: Course over ground (000 - 359 degrees, padded with 0 if leading digits are insufficient)

Field 2: T=True north reference

Field 3: Course over ground (000 - 359 degrees, padded with 0 if leading digits are insufficient)

Field 4: M=Magnetic north reference

Field 5: Ground speed (0.00, padded with 0 if leading digits are insufficient)

Field 6: N=Knots

Field 7: Ground speed (0.00, padded with 0 if leading digits are insufficient)

Field 8: K=Kilometers per hour (km/h)

Field 9: Status indicator, E(Dead reckoning), A(Non-DGPS fix)

Basic format of the RMC sentence:

$GPRMC,(1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13)*hh(CR)(LF)

Field 1: UTC time, in hhmmss.sss format

Field 2: Status, A=Valid fix, V=Invalid fix

Field 3: Latitude, in ddmm.mmmm format (padded with 0 if leading digits are insufficient)

Field 4: Latitude hemisphere, N (North) or S (South)

Field 5: Longitude, in dddmm.mmmm format (padded with 0 if leading digits are insufficient)

Field 6: Longitude hemisphere, E (East) or W (West)

Field 7: Speed over ground, in Knots

Field 8: Course over ground, in degrees

Field 9: UTC date, in DDMMYY format

Field 10: Magnetic variation (000 - 180 degrees, padded with 0 if leading digits are insufficient)

Field 11: Magnetic variation direction, E=East, W=West

Field 12: Status indicator, E(Dead reckoning), A(Non-DGPS fix)

Field 13: Navigation status, V=Navigation status not available

Basic format of the DTM sentence:

$GNDTM,<1>,<2>,<3>,<4>,<5>,<6>,<7>,<8>*<9>(CR)(LF)

<1> Local datum code (e.g. W84, P90)

<2> Datum subcode (empty)

<3> Latitude offset

<4> Latitude hemisphere, N (North) or S (South)

<5> Longitude offset

<6> Longitude hemisphere, E (East) or W (West)

<7> Altitude offset

<8> Reference datum code (W84)

<9> Checksum

Basic format of the GNS sentence:

$GNGNS,<1>,<2>,<3>,<4>,<5>,<6>,<7>,<8>.<9>,<10>,<11>,<12>,<13>,*<14>(CR)(LF)

<1> UTC time: Fix time in hhmmss.ss format (000000.00~235959.99)

<2> Latitude: in ddmm.mmmmm format (0000.00000~8959.9999)

<3> Latitude hemisphere: N for North, S for South

<4> Longitude: in dddmm.mmmmm format (0000.00000~17959.99999)

<5> Longitude hemisphere: E for East, W for West

<6> Positioning mode: N=No fix; A=Autonomous fix; D=Differential fix; P=Precise point positioning; R=RTK fixed; F=RTK float; E=Estimated; M=Manual input; S=Simulated

<7> Number of satellites used in positioning (00-99)

<8> HDOP (Horizontal Dilution of Precision) (0.5-99.9)

<9> Altitude above mean sea level, unit: meters

<10> Geoidal separation: Height of the geoid above the WGS84 ellipsoid

<11> Age of differential data: Empty for GN-prefixed sentences

<12> Base station ID: Empty for GN-prefixed sentences

<13> Navigation status: C=Caution, S=Safe, U=Unsafe, V=Invalid

<14> Checksum

Top comments (0)