GNSS Module

GNSS Module is a global positioning wireless communication module featuring the NEO-M9N-00B GPS module. It incorporates BMI270, BMM150 and a barometric pressure sensor.

Support the following products:

GNSSModule

Micropython Example:

  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 GNSSModule
  9
 10
 11title0 = None
 12label3 = None
 13label4 = None
 14label5 = None
 15label6 = None
 16label10 = None
 17label11 = None
 18label12 = None
 19label13 = None
 20label14 = None
 21label15 = None
 22label16 = None
 23label17 = None
 24label18 = None
 25label19 = None
 26label20 = None
 27label21 = None
 28label22 = None
 29label23 = None
 30line0 = None
 31gnss_0 = None
 32
 33
 34list2 = None
 35
 36
 37def setup():
 38    global \
 39        title0, \
 40        label3, \
 41        label4, \
 42        label5, \
 43        label6, \
 44        label10, \
 45        label11, \
 46        label12, \
 47        label13, \
 48        label14, \
 49        label15, \
 50        label16, \
 51        label17, \
 52        label18, \
 53        label19, \
 54        label20, \
 55        label21, \
 56        label22, \
 57        label23, \
 58        line0, \
 59        gnss_0, \
 60        list2
 61
 62    M5.begin()
 63    Widgets.fillScreen(0x222222)
 64    title0 = Widgets.Title(
 65        "            M135 GNSS Demo", 3, 0xFFFFFF, 0x0000FF, Widgets.FONTS.DejaVu18
 66    )
 67    label3 = Widgets.Label("angle:", 2, 23, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
 68    label4 = Widgets.Label(
 69        "attitude(yaw):", 1, 73, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18
 70    )
 71    label5 = Widgets.Label("temp:", 4, 128, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
 72    label6 = Widgets.Label("pressure:", 2, 180, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
 73    label10 = Widgets.Label("label10", 4, 46, 1.0, 0x3EF815, 0x222222, Widgets.FONTS.DejaVu18)
 74    label11 = Widgets.Label("label11", 5, 102, 1.0, 0xF60505, 0x222222, Widgets.FONTS.DejaVu18)
 75    label12 = Widgets.Label("label12", 5, 154, 1.0, 0x3EF815, 0x222222, Widgets.FONTS.DejaVu18)
 76    label13 = Widgets.Label("label13", 5, 208, 1.0, 0xF60505, 0x222222, Widgets.FONTS.DejaVu18)
 77    label14 = Widgets.Label("lat:", 158, 51, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
 78    label15 = Widgets.Label("long:", 157, 80, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
 79    label16 = Widgets.Label("sta:", 158, 24, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
 80    label17 = Widgets.Label("date:", 158, 108, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
 81    label18 = Widgets.Label("time:", 159, 168, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
 82    label19 = Widgets.Label("label19", 159, 138, 1.0, 0x15F0FF, 0x222222, Widgets.FONTS.DejaVu18)
 83    label20 = Widgets.Label("label20", 159, 197, 1.0, 0xEAFF00, 0x222222, Widgets.FONTS.DejaVu18)
 84    label21 = Widgets.Label("label21", 205, 25, 1.0, 0xFFFFFF, 0x222222, Widgets.FONTS.DejaVu18)
 85    label22 = Widgets.Label("label22", 205, 52, 1.0, 0x15F0FF, 0x222222, Widgets.FONTS.DejaVu18)
 86    label23 = Widgets.Label("label23", 205, 81, 1.0, 0xEAFF00, 0x222222, Widgets.FONTS.DejaVu18)
 87    line0 = Widgets.Line(142, 27, 142, 232, 0xFFFFFF)
 88
 89    gnss_0 = GNSSModule(2, 13, 14, 0x69)
 90
 91
 92def loop():
 93    global \
 94        title0, \
 95        label3, \
 96        label4, \
 97        label5, \
 98        label6, \
 99        label10, \
100        label11, \
101        label12, \
102        label13, \
103        label14, \
104        label15, \
105        label16, \
106        label17, \
107        label18, \
108        label19, \
109        label20, \
110        label21, \
111        label22, \
112        label23, \
113        line0, \
114        gnss_0, \
115        list2
116    M5.update()
117    label10.setText(str(gnss_0.get_compass()))
118    label11.setText(str((gnss_0.get_attitude())[0]))
119    label12.setText(str(gnss_0.get_temperature()))
120    label13.setText(str(gnss_0.get_pressure()))
121    if gnss_0.is_locate_valid():
122        label21.setText(str("OK"))
123    else:
124        label21.setText(str("Failed"))
125    label22.setText(str(gnss_0.get_latitude()))
126    label23.setText(str(gnss_0.get_longitude()))
127    label19.setText(str(gnss_0.get_date()))
128    label20.setText(str(gnss_0.get_time()))
129
130
131if __name__ == "__main__":
132    try:
133        setup()
134        while True:
135            loop()
136    except (Exception, KeyboardInterrupt) as e:
137        try:
138            from utility import print_error_msg
139
140            print_error_msg(e)
141        except ImportError:
142            print("please update to latest firmware")

UIFLOW2 Example:

example.png

gnss_core2_example.m5f2

class GNSSModule

Constructors

class GNSSModule(id, rx, tx, address)

initialize Function.

Parameters:
  • id (int) – UART controllers id, the range is 0 to 2.

  • rx (int) – UART rx pin.

  • tx (int) – UART tx pin.

  • address (int)

UIFLOW2:

init.png

Methods

GNSSModule.set_accel_gyro_odr(accel_odr, gyro_odr)

Set the accelerometer and gyroscope output data rate.

Parameters:
  • accel_odr – range of 0.78 Hz … 1.6 kHz. Options: - 25: 25 - 50: 50 - 100: 100 - 200: 200 - 400: 400 - 800: 800 - 1600: 1600 - 0.78: 0.78 - 1.5: 1.5 - 3.1: 3.1 - 6.25: 6.25 - 12.5: 12.5

  • gyro_odr – range of 25 Hz … 6.4 kHz. Options: - 25: 25 - 50: 50 - 100: 100 - 200: 200 - 400: 400 - 800: 800 - 1600: 1600 - 3200: 3200

UIFLOW2:

set_accel_gyro_odr.png

GNSSModule.set_accel_range(accel_scale)

Set the accelerometer scale range.

Parameters:

accel_scale – scale range of ±2g, ±4g, ±8g and ±16g. Options: - 2: 2 - 4: 4 - 8: 8 - 16: 16

UIFLOW2:

set_accel_range.png

GNSSModule.set_gyro_range(gyro_scale)

Set the gyroscope scale range.

Parameters:

gyro_scale – Options: - 125: 125 - 250: 250 - 500: 500 - 1000: 1000 - 2000: 2000

UIFLOW2:

set_gyro_range.png

GNSSModule.set_magnet_odr(magnet_odr)
Parameters:

magnet_odr – Options: - 2: 2 - 6: 6 - 8: 8 - 10: 10 - 15: 15 - 20: 20 - 25: 25 - 30: 30

UIFLOW2:

set_magnet_odr.png

GNSSModule.set_gyro_offsets(x, y, z)

Set the manual gyro calibrations offsets value.

Parameters:
  • x – gyro calibrations offsets value of X-axis

  • y – gyro calibrations offsets value of Y-axis

  • z – gyro calibrations offsets value of Z-axis

UIFLOW2:

set_gyro_offsets.png

GNSSModule.get_gyroscope()

Get the tuple of x, y, and z values of the gyroscope and gyroscope vector in rad/sec.

Return (tuple):

gyroscope tuple (float, float, float)

UIFLOW2:

get_gyroscope.png

GNSSModule.get_accelerometer()

Get the tuple of x, y, and z values of the accelerometer and acceleration vector in gravity units (9.81m/s^2).

Return (tuple):

accelerometer tuple (float, float, float)

UIFLOW2:

get_accelerometer.png

GNSSModule.get_magnetometer()

Get the tuple of x, y, and z values of the magnetometer and magnetometer vector in uT.

Return (tuple):

magnetometer tuple (float, float, float)

UIFLOW2:

get_magnetometer.png

GNSSModule.get_compass()

Get the compass heading value is in range of 0º ~ 360º.

Return (float):

range is 0 to 360 degree

UIFLOW2:

get_compass.png

GNSSModule.get_attitude()

Get the attitude angles as yaw, pitch, and roll in degrees.

Return (tuple):

tuple of yaw, pitch, and roll (float, float, float)

UIFLOW2:

get_attitude.png

GNSSModule.get_temperature()

Get the temperature value in degrees celsius from the BMP280 sensor.

Return (float):

range is -40 ~ +85 °C.

UIFLOW2:

get_temperature.png

GNSSModule.get_pressure()

Get the pressure value in pascals from the BMP280 sensor.

Return (float):

range is 300 ~ 1100 hPa.

UIFLOW2:

get_pressure.png

GNSSModule.set_time_zone(value)

set timezone function.

Parameters:

value (int) – timezone value

UIFLOW2:

set_time_zone.png

GNSSModule.get_time_zone()

get timezone function.

Return (int):

timezone value

UIFLOW2:

get_time_zone.png

GNSSModule.get_satellite_num()

get satellite numbers.

Return (str):

satellite numbers value.

UIFLOW2:

get_satellite_num.png

GNSSModule.get_altitude()

get altitude.

Return (str):

altitude unit is meter.

UIFLOW2:

get_altitude.png

GNSSModule.get_time()

get time.

Return (str):

time(hh:mm:ss)

UIFLOW2:

get_time.png

GNSSModule.get_date()

get date.

Return (str):

date(dd/mm/yy)

UIFLOW2:

get_date.png

GNSSModule.get_latitude()

get latitude.

Return (str):

latitude, using degrees minutes format (ddmm.mmmmmN/S).

UIFLOW2:

get_latitude.png

GNSSModule.get_longitude()

get longitude.

Return (str):

longitude, using degrees minutes format (ddmm.mmmmmE/W).

UIFLOW2:

get_longitude.png

GNSSModule.get_latitude_decimal()

get latitude decimal.

Return (float):

latitude decimal(dd.dddd).

UIFLOW2:

get_latitude_decimal.png

GNSSModule.get_longitude_decimal()

get longitude decimal.

Return (float):

longitude decimal(dd.dddd).

UIFLOW2:

get_longitude_decimal.png

GNSSModule.get_speed(type)

get speed.

Return (str):

speed.

Parameters:

type (int) – speed type, 0 km/h, 1 knot/h Options: - km/h: 0 - knot/h: 1

UIFLOW2:

get_speed.png

GNSSModule.get_course()

get course.

Return (str):

course unit is °.

UIFLOW2:

get_course.png

GNSSModule.is_locate_valid()

get locate status.

Return (bool):

locate status, true is locate, false is not locate.

UIFLOW2:

is_locate_valid.png