Atomic GPS Base v2.0

This is the driver library for the Atomic GPS Base v2.0, which is used to get the GPS data.

Support the following products:

Atom GPS Base v2.0

UiFlow2 Example

get GPS data

Open the base_gpsv2_atom_example.m5f2 project in UiFlow2.

This example demonstrates how to get the GPS data using Atomic GPS Base v2.0.

UiFlow2 Code Block:

example.png

Example output:

None

MicroPython Example

get GPS data

This example demonstrates how to get the GPS data using Atomic GPS Base v2.0.

MicroPython Code Block:

 1# SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD
 2#
 3# SPDX-License-Identifier: MIT
 4
 5import os, sys, io
 6import M5
 7from M5 import *
 8from hardware import RGB
 9from base import AtomicGPSV2Base
10import time
11
12
13rgb = None
14base_gpsv2 = None
15
16
17def setup():
18    global rgb, base_gpsv2
19
20    M5.begin()
21    rgb = RGB()
22    rgb.set_screen([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
23    rgb.set_brightness(20)
24    rgb.fill_color(0x33FF33)
25    base_gpsv2 = AtomicGPSV2Base(2, port=(22, 19))
26    base_gpsv2.set_work_mode(7)
27    base_gpsv2.set_time_zone(0)
28
29
30def loop():
31    global rgb, base_gpsv2
32    M5.update()
33    print((str("longitude:") + str((base_gpsv2.get_longitude()))))
34    print((str("altitude:") + str((base_gpsv2.get_altitude()))))
35    print((str("latitude:") + str((base_gpsv2.get_latitude()))))
36    time.sleep(1)
37
38
39if __name__ == "__main__":
40    try:
41        setup()
42        while True:
43            loop()
44    except (Exception, KeyboardInterrupt) as e:
45        try:
46            from utility import print_error_msg
47
48            print_error_msg(e)
49        except ImportError:
50            print("please update to latest firmware")

Example output:

None

API

AtomicGPSV2Base

class base.gpsv2.AtomicGPSV2Base(id=1, port=None, verbose=False)

Bases: ATGM336H

Create an AtomicGPSV2Base object.

Parameters:
  • id (int) – The UART ID for communication with the GPS module. It can be 1, or 2.

  • port (list | tuple) – A list or tuple containing the TX and RX pins for UART communication.

  • verbose (bool) – Whether to print verbose output.

UIFlow Code Block:

init.png

MicroPython Code Block:

from base.gpsv2 import AtomicGPSV2Base

gps_0 = AtomicGPSV2Base(id=1, tx=5, rx=6)
class driver.atgm336h.ATGM336H(id, tx, rx, pps=None, rst=None, verbose=False)

Bases: object

Create an ATGM336H object.

Parameters:
  • id (int) – The UART ID for communication with the GPS module. It can be 1, or 2.

  • tx (int) – The TX pin is the pin that sends data to the GPS module.

  • rx (int) – The RX pin is the pin that receives data from the GPS module.

  • pps (int) – The PPS pin is the pin that receives the PPS signal from the GPS module.

  • verbose (bool) – Whether to print verbose output.

MicroPython Code Block:

from driver.atgm336h import ATGM336H

gps_0 = ATGM336H(id=2, tx=5, rx=6)
set_work_mode(mode)

Set the working mode of the GPS module.

Parameters:

mode (int) – The mode to set, defined by the GPS module.

UiFlow2 Code Block:

set_work_mode.png

MicroPython Code Block:

gps_0.set_work_mode(7)
get_work_mode()

Get the current working mode of the GPS module.

Returns:

The current working mode of the GPS module.

Return type:

int

UiFlow2 Code Block:

get_work_mode.png

MicroPython Code Block:

gps_0.get_work_mode()
get_antenna_state()

Get the state of the antenna.

Returns:

The antenna state.

Return type:

str

MicroPython Code Block:

gps_0.get_antenna_state()
get_gps_time()

Get the current GPS time.

Returns:

The GPS time as a list of strings [hour, minute, second].

Return type:

list[str]

UiFlow2 Code Block:

get_gps_time.png

MicroPython Code Block:

gps_0.get_gps_time()
get_gps_date()

Get the current GPS date.

Returns:

The GPS date as a list of strings [year, month, day].

Return type:

list[str]

UiFlow2 Code Block:

get_gps_date.png

MicroPython Code Block:

gps_0.get_gps_date()
get_gps_date_time()

Get the current GPS date and time combined.

Returns:

The GPS date and time as a list of strings [year, month, day, hour, minute, second].

Return type:

list[str]

UiFlow2 Code Block:

get_gps_date_time.png

MicroPython Code Block:

gps_0.get_gps_date_time()
get_timestamp()

Get the timestamp of the current GPS time.

Returns:

The timestamp representing the current GPS time.

Return type:

int | float

UiFlow2 Code Block:

get_timestamp.png

MicroPython Code Block:

gps_0.get_timestamp()
get_latitude()

Get the current latitude.

Returns:

The current latitude in string format.

Return type:

str

UiFlow2 Code Block:

get_latitude.png

MicroPython Code Block:

gps_0.get_latitude()
get_longitude()

Get the current longitude.

Returns:

The current longitude in string format.

Return type:

str

UiFlow2 Code Block:

get_longitude.png

MicroPython Code Block:

gps_0.get_longitude()
get_altitude()

Get the current altitude.

Returns:

The current altitude in string format.

Return type:

str

UiFlow2 Code Block:

get_altitude.png

MicroPython Code Block:

gps_0.get_altitude()
get_satellite_num()

Get the number of satellites used for positioning.

Returns:

The number of satellites.

Return type:

str

UiFlow2 Code Block:

get_satellite_num.png

MicroPython Code Block:

gps_0.get_satellite_num()
get_pos_quality()

Get the quality of the GPS position.

Returns:

The position quality indicator.

Return type:

str

UiFlow2 Code Block:

get_pos_quality.png

MicroPython Code Block:

gps_0.get_pos_quality()
get_course_over_ground()

Get the course over ground (COG).

Note: Only data returned by the satellite is extracted. If the data does not display properly, it indicates that the satellite did not actually return that data.

Returns:

The course over ground in degrees.

Return type:

str

UiFlow2 Code Block:

get_course_over_ground.png

MicroPython Code Block:

gps_0.get_course_over_ground()
get_speed_over_ground()

Get the speed over ground (SOG).

Returns:

The speed over ground in knots.

Return type:

str

UiFlow2 Code Block:

get_speed_over_ground.png

MicroPython Code Block:

gps_0.get_speed_over_ground()
set_time_zone(value)

Set the time zone offset for the GPS time.

Parameters:

value (int) – The time zone offset value to set.

UiFlow2 Code Block:

set_time_zone.png

MicroPython Code Block:

gps_0.set_time_zone(1)
get_time_zone()

Get the current time zone offset.

Returns:

The current time zone offset.

Return type:

int

UiFlow2 Code Block:

get_time_zone.png

MicroPython Code Block:

gps_0.get_time_zone()
deinit()

Deinitialize the GPS unit, stopping any running tasks and releasing resources.

UiFlow2 Code Block:

deinit.png

MicroPython Code Block:

gps_0.deinit()