Atomic GPS Base

This is the driver library of ATOM GPS Base, which is used to obtain data from the GPS module.

Support the following products:

ATOM GPS

ATOM GPS Base

UiFlow2 Example

get gps data

Open the atoms3_gps_example.m5f2 project in UiFlow2.

This example gets the GPS data of the ATOM GPS Base and displays it on the serial monitor.

UiFlow2 Code Block:

example.png

Example output:

None

MicroPython Example

get gps data

This example gets the GPS data of the ATOM GPS Base and displays it on the serial monitor.

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 base import ATOMGPSBase
 9import time
10
11
12title0 = None
13base_gps = None
14
15
16def setup():
17    global title0, base_gps
18
19    M5.begin()
20    title0 = Widgets.Title("GPS Base", 3, 0xFFFFFF, 0x0000FF, Widgets.FONTS.DejaVu18)
21
22    base_gps = ATOMGPSBase(2, port=(5, 6))
23    base_gps.set_time_zone(0)
24
25
26def loop():
27    global title0, base_gps
28    M5.update()
29    print(base_gps.get_gps_time())
30    print(base_gps.get_gps_date())
31    print(base_gps.get_gps_date_time())
32    print(base_gps.get_timestamp())
33    print(base_gps.get_latitude())
34    print(base_gps.get_longitude())
35    print(base_gps.get_altitude())
36    print(base_gps.get_satellite_num())
37    print(base_gps.get_pos_quality())
38    print(base_gps.get_corse_over_ground())
39    print(base_gps.get_speed_over_ground())
40    time.sleep(1)
41
42
43if __name__ == "__main__":
44    try:
45        setup()
46        while True:
47            loop()
48    except (Exception, KeyboardInterrupt) as e:
49        try:
50            from utility import print_error_msg
51
52            print_error_msg(e)
53        except ImportError:
54            print("please update to latest firmware")

Example output:

None

API

ATOMGPSBase

class base.atom_gps.ATOMGPSBase(id=1, port=None, debug=False)

Bases: object

Create an ATOMGPSBase object.

Parameters:
  • id (int) – The UART ID to use (0, 1, or 2). Default is 2.

  • port (list | tuple) – A list or tuple containing the TX and RX pin numbers.

  • debug (bool) – Whether to enable debug mode. Default is False.

UiFlow2 Code Block:

init.png

MicroPython Code Block:

from machine import UART
from base import ATOMGPSBase

gps = ATOMGPSBase(id=1, port=(16, 17))
get_antenna_state()

Get the state of the antenna.

Returns:

The current antenna state.

Return type:

str

UiFlow2 Code Block:

get_antenna_state.png

MicroPython Code Block:

gps.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.get_gps_time()
get_gps_date()

Get the current GPS date.

Returns:

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

Return type:

list[str]

UiFlow2 Code Block:

get_gps_date.png

MicroPython Code Block:

gps.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.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.get_timestamp()
get_latitude()

Get the current latitude.

Returns:

The current latitude.

Return type:

str

UiFlow2 Code Block:

get_latitude.png

MicroPython Code Block:

gps.get_latitude()
get_longitude()

Get the current longitude.

Returns:

The current longitude.

Return type:

str

UiFlow2 Code Block:

get_longitude.png

MicroPython Code Block:

gps.get_longitude()
get_altitude()

Get the current altitude.

Returns:

The current altitude.

Return type:

str

UiFlow2 Code Block:

get_altitude.png

MicroPython Code Block:

gps.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.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.get_pos_quality()
get_corse_over_ground()

Get the course over ground (COG).

Returns:

The course over ground in degrees.

Return type:

str

UiFlow2 Code Block:

get_corse_over_ground.png

MicroPython Code Block:

gps.get_corse_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.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.

Return type:

None

UiFlow2 Code Block:

set_time_zone.png

MicroPython Code Block:

gps.set_time_zone(8)
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.get_time_zone()
deinit()

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

UiFlow2 Code Block:

deinit.png

MicroPython Code Block:

gps.deinit()
Return type:

None