GPS V2.0 Module

GPS v2.0 模块是一款高性能 GNSS 全球定位模块,集成高性能 AT6668 芯片,可提供精准、可靠的卫星定位服务。该模块支持多频、多模式 GNSS 信号接收,兼容多种卫星导航系统,包括 GPS、BD2、BD3、GLONASS、GALILEO 和 QZSS,可实现高精度的多系统联合定位或单系统独立定位,并具备出色的抗干扰能力。在弱信号区域,也能快速获取更高精度的定位信息。模块配备外置 SMA 天线,并带有拨码开关,便于用户灵活切换 TX/RX 通信引脚,同时提供 PPS 信号输出,用于精确定时校准。支持多堆叠使用,提供更多定制与灵活性,适用于车载导航、IoT 定位设备、远程监控、智慧城市以及家庭与工业自动化等高精度定位应用场景。

支持以下产品:

GPSV2Module

MicroPython 应用示例:

 1# SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
 2#
 3# SPDX-License-Identifier: MIT
 4
 5import os, sys, io
 6import M5
 7from M5 import *
 8from module import GPSV2Module
 9import time
10
11
12label0 = None
13title0 = None
14label1 = None
15label2 = None
16label3 = None
17label4 = None
18label5 = None
19label6 = None
20module_gpsv2_0 = None
21
22
23power_on_time = None
24
25
26def setup():
27    global \
28        label0, \
29        title0, \
30        label1, \
31        label2, \
32        label3, \
33        label4, \
34        label5, \
35        label6, \
36        module_gpsv2_0, \
37        power_on_time
38
39    M5.begin()
40    Widgets.fillScreen(0x222222)
41    label0 = Widgets.Label("Power On:", 1, 33, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
42    title0 = Widgets.Title(
43        "GPSV2Module Core2 Example", 3, 0xFFFFFF, 0x0000FF, Widgets.FONTS.DejaVu18
44    )
45    label1 = Widgets.Label(
46        "Satellite Num:", 1, 66, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18
47    )
48    label2 = Widgets.Label("Timestamp:", 1, 202, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
49    label3 = Widgets.Label("GPS Data:", -6, 526, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
50    label4 = Widgets.Label("Latitude:", 1, 104, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
51    label5 = Widgets.Label("Longitude:", 1, 140, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
52    label6 = Widgets.Label("Altitude:", 1, 170, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
53
54    module_gpsv2_0 = GPSV2Module(2, 13, 14, 25)
55    power_on_time = time.time()
56    module_gpsv2_0.set_work_mode(7)
57
58
59def loop():
60    global \
61        label0, \
62        title0, \
63        label1, \
64        label2, \
65        label3, \
66        label4, \
67        label5, \
68        label6, \
69        module_gpsv2_0, \
70        power_on_time
71    M5.update()
72    label0.setText(str((str("Power On:") + str(((time.time()) - power_on_time)))))
73    label1.setText(str((str("Satellite Num:") + str((module_gpsv2_0.get_satellite_num())))))
74    label2.setText(str((str("Timestamp:") + str((module_gpsv2_0.get_timestamp())))))
75    label4.setText(str((str("Latitude:") + str((module_gpsv2_0.get_latitude())))))
76    label5.setText(str((str("Longitude:") + str((module_gpsv2_0.get_longitude())))))
77    label6.setText(str((str("Altitude:") + str((module_gpsv2_0.get_altitude())))))
78    time.sleep(1)
79
80
81if __name__ == "__main__":
82    try:
83        setup()
84        while True:
85            loop()
86    except (Exception, KeyboardInterrupt) as e:
87        try:
88            from utility import print_error_msg
89
90            print_error_msg(e)
91        except ImportError:
92            print("please update to latest firmware")

UiFlow2 应用示例

example.png

gpsv2_core2_example.m5f2

class GPSV2Module

Constructors

class GPSV2Module(id, rx, tx)

使用指定的 UART id 和端口初始化 GPSV2Module 以进行通信。

参数:
  • id (int) – 用于与 GPS 模块通信的 UART ID。它可以是 0、1 或 2。

  • rx – UART 的 RX 引脚。

  • tx – UART 的 TX 引脚。

UiFlow2

init.png

Methods

GPSV2Module.set_work_mode(mode)

设置 GPS 模块的工作模式。

参数:

mode (int) – 要设置的模式,由 GPS 模块定义。

UiFlow2

set_work_mode.png

GPSV2Module.get_work_mode()

获取 GPS 模块当前的工作模式。

返回:

GPS 模块的当前工作模式。

UiFlow2

get_work_mode.png

GPSV2Module.get_antenna_state()

获取天线的状态。

返回:

天线状态。

UiFlow2

get_antenna_state.png

GPSV2Module.get_gps_time()

获取当前 GPS 时间。

返回:

GPS 时间,以字符串列表形式表示 [hour, minute, second]。

UiFlow2

get_gps_time.png

GPSV2Module.get_gps_date()

获取当前 GPS 日期。

返回:

GPS 日期,以字符串列表形式表示 [day, month, year]。

UiFlow2

get_gps_date.png

GPSV2Module.get_gps_date_time()

获取当前 GPS 日期和时间(组合)。

返回:

GPS 日期和时间,以字符串列表形式表示 [year, month, day, hour, minute, second]。

UiFlow2

get_gps_date_time.png

GPSV2Module.get_timestamp()

获取当前 GPS 时间的时间戳。

返回:

表示当前 GPS 时间的时间戳。

UiFlow2

get_timestamp.png

GPSV2Module.get_latitude()

获取当前纬度。

返回:

当前纬度的字符串格式。

UiFlow2

get_latitude.png

GPSV2Module.get_longitude()

获取当前经度。

返回:

当前经度的字符串格式。

UiFlow2

get_longitude.png

GPSV2Module.get_altitude()

获取当前海拔高度。

返回:

当前海拔的字符串格式。

UiFlow2

get_altitude.png

GPSV2Module.get_satellite_num()

获取用于定位的卫星数量。

返回:

卫星数量。

UiFlow2

get_satellite_num.png

GPSV2Module.get_pos_quality()

获取 GPS 位置的质量。

返回:

位置质量指示器。

UiFlow2

get_pos_quality.png

GPSV2Module.get_corse_over_ground()

获取地面航向(COG)。

返回:

地面航向,单位为度。

UiFlow2

get_corse_over_ground.png

GPSV2Module.get_speed_over_ground()

获取对地速度(SOG)。

返回:

地面速度,单位为节。

UiFlow2

get_speed_over_ground.png

GPSV2Module.set_time_zone(value)

设置 GPS 时间的时区偏移量。

参数:

value – 要设置的时区偏移值。

UiFlow2

set_time_zone.png

GPSV2Module.get_time_zone()

获取当前时区偏移量。

返回:

当前时区偏移量。

UiFlow2

get_time_zone.png

GPSV2Module.deinit()

反初始化 GPS 单元,停止任何正在运行的任务并释放资源。

UiFlow2

deinit.png

GPSV2Module._add_checksum(message)

为与 GPS 模块通信的消息添加校验和。

参数:

message (str) – 将要添加校验和的消息。

返回:

添加了校验和的消息。

GPSV2Module._decode_gga(data)

解码 GGA 语句以提取 GPS 质量、卫星数量和海拔高度。

参数:

data (str) – 要解码的 GGA 语句。

GPSV2Module._decode_rmc(data)

解码 RMC 语句以提取 GPS 时间、纬度、经度、速度、航向和日期。

参数:

data (str) – 要解码的 RMC 语句。

GPSV2Module._decode_txt(data)

解码 TXT 句子以提取天线状态。

参数:

data (str) – 用于解码的 TXT 语句。

GPSV2Module._monitor()

监控 GPS 数据并解码传入的语句。