Template: Pico-GPS-L76B-Manual

From Waveshare Wiki
Jump to: navigation, search


Sample program brief analysis

  • Note that the value in the form of dd used in the creation of the NMEA0183 sentence parser type in coordinates_converter.py, initializing to other forms such as ddm, dms form of latitude and longitude value requires rewriting the coordinate conversion function.
# make an object of NMEA0183 sentence parser
"""
Setup GPS Object Status Flags, Internal Data Registers, etc
local_offset (int): Timzone Difference to UTC
location_formatting (str): Style For Presenting Longitude/Latitude:
                           Decimal Degree Minute (ddm) - 40° 26.767′ N
                           Degrees Minutes Seconds (dms) - 40° 26′ 46″ N
                           Decimal Degrees (dd) - 40.446° N
"""
parser = MicropyGPS(location_formatting='dd')
  • The coordinates_converter.py file converts NMEA0183 sentences into WGS84 coordinate latitude and longitude values and BD09 coordinate system latitude and longitude values, which are respectively suitable for coordinate labeling on Google Maps, Baidu Maps, etc.
while True:
    if gnss_l76b.uart_any():
        sentence = parser.update(chr(gnss_l76b.uart_receive_byte()[0]))
        if sentence:
            
            print('WGS84 Coordinate:Latitude(%c),Longitude(%c) %.9f,%.9f'%(parser.latitude[1],parser.longitude[1],parser.latitude[0],parser.longitude[0]))
            print('copy WGS84 coordinates and paste it on Google map web https://www.google.com/maps')

            gnss_l76b.wgs84_to_bd09(parser.longitude[0],parser.latitude[0])
            print('Baidu Coordinate: longitude(%c),latitudes(%c) %.9f,%.9f'%(parser.longitude[1],parser.latitude[1],gnss_l76b.Lon_Baidu,gnss_l76b.Lat_Baidu))
            print('copy Baidu Coordinate and paste it on the baidu map web https://api.map.baidu.com/lbsapi/getpoint/index.html')
            
            print('UTC Timestamp:%d:%d:%d'%(parser.timestamp[0],parser.timestamp[1],parser.timestamp[2]))
            
#           print fix status
            '''
            1 : NO FIX
            2 : FIX 2D
            3 : FIX_3D
            '''
            print('Fix Status:', parser.fix_stat)
            
            print('Altitude:%d m'%(parser.altitude))
            print('Height Above Geoid:', parser.geoid_height)
            print('Horizontal Dilution of Precision:', parser.hdop)
            print('Satellites in Use by Receiver:', parser.satellites_in_use)
            print('')
  • The gnss_setting.py file lists the L76B related setting information, the NMEA output frequency in the following code, and related settings such as hot start.
# set NMEA0183 sentence output frequence
'''
optional:
SET_POS_FIX_100MS
SET_POS_FIX_200MS
SET_POS_FIX_400MS
SET_POS_FIX_800MS
SET_POS_FIX_1S
SET_POS_FIX_2S
SET_POS_FIX_4S
SET_POS_FIX_8S
SET_POS_FIX_10S
'''
gnss_l76b.L76X_Send_Command(gnss_l76b.SET_POS_FIX_1S)

#set #Startup mode
'''
    SET_HOT_START
    SET_WARM_START
    SET_COLD_START
    SET_FULL_COLD_START
'''
gnss_l76b.L76X_Send_Command(gnss_l76b.SET_COLD_START)