Latest posts made by UnumDesignum
-
[SOLVED] GNSS on Core2: BMM150 issue when using M5 events
Hello,
I'm developing a program that uses the GPS and the Magnetometer (BMM150) of the GNSS Module.
It works fine, but as soon as functions such as M5.BtnA.wasPressed(), screen touch or M5.Axp.GetBatVoltage(), the BMM150 communication seems broken.I tried with address 0x68 and 0x69 -> same problem.
I tried running the task on core 1 or core 0 -> same problem.DO YOU HAVE AN IDEA OF WHAT I'M DOING WRONG HERE?
Examples of error displayed on the monitor.
After M5.Axp.GetBatVoltage() called:
11:59:50.763 -> E (22261) IMU: P:0 R 68 7C E:263After M5.BtnA.wasPressed() called:
12:00:33.754 -> E (16003) IMU: P:0 R 68 7C E:-1
12:00:34.119 -> E (16025) IMU: P:0 R 68 03 E:263
12:00:34.149 -> E (16038) IMU: P:0 R 68 03 E:263Source code to reproduce the issue.
M5Module_GNSS.h is available here: https://github.com/m5stack/M5Module-GNSS/tree/main/src
#include <M5Core2.h>
#include <Arduino.h>
#include <TinyGPS++.h>
#include <Wire.h>
#include "M5Module_GNSS.h"#define BIM270_SENSOR_ADDR 0x68
BMI270::BMI270 bmi270;#define WATCHDOG_TIMER 2000UL // ms
#define BATT_CHECK 20000UL // ms - interval to check battery status// variables
uint32_t last_battery_check = 0;
uint32_t last_json = 0;bool isGPS = false;
// GPS & Magnetometer
float biasX, biasY, rangeX, rangeY;
int16_t magX, magY, magZ;
int16_t minMagX, minMagY, maxMagX, maxMagY;
// The TinyGPS++ object
TinyGPSPlus gps;// functions
void gps_task(void *pvParameters);
void magneto_task(void *pvParameters);void updateBatteryLevel (void) {
float batVoltage = M5.Axp.GetBatVoltage();
float batPercentage = ( batVoltage < 3.2 ) ? 0 : ( batVoltage - 3.2 ) * 100;
Serial.printf("Battery %d\n", batPercentage);
}// ------------------------------------------------ SETUP -----------------------------------------------
void setup() {
magX = 0;
magY = 0;M5.begin(true, true, true, false, kMBusModeOutput);
M5.Axp.SetLed(0);
M5.Lcd.begin();xTaskCreatePinnedToCore(gps_task,
"gps_task",
10000,
NULL,
25,
NULL,
0); // running on core 0xTaskCreatePinnedToCore(magneto_task,
"magneto_task",
10000,
NULL,
25,
NULL,
1); // running on core 0return;
}void magneto_task(void *pvParameters) {
static int data, cpmt = 100;
Serial.print("MAGNETO TASK STARTS\n");
Wire.begin(21, 22, 100000);
bmi270.init(I2C_NUM_0, BIM270_SENSOR_ADDR);while (1) {
// DEBUG
cpmt++;
if ( cpmt > 100 ) {
Serial.print("•");
cpmt = 0;
};
// Get Magnetometer data
if (bmi270.magneticFieldAvailable()) {
bmi270.readMagneticField(magX, magY, magZ);
}
if (cpmt ==0) Serial.printf("x %d y %d\n", magX, magY);
delay(10);
}
}void gps_task(void *pvParameters) {
static int data, cpmt = 100;
Serial.print("GPS TASK STARTS\n");
Serial2.begin(38400, SERIAL_8N1, 13, 14);while (1) {
// DEBUG
cpmt++;
if ( cpmt > 100 ) {
Serial.print("+");
cpmt = 0;
};
// Get GPS data
while (Serial2.available() > 0) {
data = Serial2.read();
//Serial.printf("%c", data);
gps.encode(data);
}
isGPS = gps.location.isValid();
delay(10);
}
}// ------------------------------------------------ LOOP -----------------------------------------------
void loop() {
static char text[256];
static uint32_t msecs;M5.update();
msecs = millis();// WATCHDOG
if ((msecs - last_json) > WATCHDOG_TIMER) {
if (isGPS) sprintf(text, "GPS %d - ", gps.satellites.value());
else sprintf(text, "Sat %d - ", gps.satellites.value());
Serial.println(text);
last_json = msecs;
}// battery timer
if ((msecs - last_battery_check) > BATT_CHECK) {
updateBatteryLevel();
last_battery_check = msecs;
}if (M5.BtnA.wasPressed()) {
Serial.println("BtnA pressed");
}if (M5.BtnB.wasPressed()) {
Serial.println("BtnB pressed");
}if (M5.BtnC.wasPressed()) {
Serial.println("BtnB pressed");
}return;
} -
RE: Unable to read data from GNSS Module with Core 2
For information to future readers, this morning one device Core2+GNSS suddenly started to work without any changes. The other one (same hw/sw) is now able to see satellites (between 11 to 14) but is totally unable to get a fix.
~~I wanted to use the magnetic gyroscope (BMM150) as well, but the data seems crazy and I cannot get any heading from them. Moreover, since this morning, the BIM270 initialisation is not more working.
So I give up this module and I will use another GPS solution.~~
Edit: thanks to M5Stack Support, the GNSS modules work fine now.
The magnetic gyroscope BMM150, as other magnetometer requires a proper calibration to be used. -
RE: Unable to read data from GNSS Module with Core 2
I connected the module to the u-center app to have more information, but nothing helpful here.
The GNSS module does not see any satellite (GSV sentences).
Is there any GPS expert able to check the configuration ?
-
RE: Unable to read data from GNSS Module with Core 2
@robski yes I did. At 38400 I have a communication with the GNSS module. At other baud rates, I've got nothing.
Issue is not to communicate with the module, it is that the module does not return any valid position.After some researches, my understanding is that I need to find out how to configure the GNSS module to make it work in my location (France). It seems that the actual configuration does not work. I'm learning the uBlox PBX commands as we speak.
-
RE: Unable to read data from GNSS Module with Core 2
@unumdesignum The data returned by the GNSS module in ASCII:
$GNRMC,,V,,,,,,,,,,N,V37
$GNVTG,,,,,,,,,N2E
$GNGGA,,,,,,0,00,99.99,,,,,,56
$GNGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99,133
$GNGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99,230
$GNGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99,331
$GNGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99,436
$GPGSV,1,1,00,164
$GLGSV,1,1,00,178
$GAGSV,1,1,00,773
$GBGSV,1,1,00,176
$GNGLL,,,,,,V,N7A -
RE: Unable to read data from GNSS Module with Core 2
@robski Thank you for your message. I tried to set dip 1 to on but without any success nor changes.
(I actually wonder what this PPS is)There are data coming out from Serial2, but it seems that they cannot be decoded by tinyGPS.
0x24 0x47 0x4e 0x52 0x4d 0x43 0x2c 0x2c 0x56 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x4e 0x2c 0x56 0x2a 0x33 0x37 0x0d 0x0a 0x24 0x47 0x4e 0x56 0x54 0x47 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x4e 0x2a 0x32 0x45 0x0d 0x0a 0x24 0x47 0x4e 0x47 0x47 0x41 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x30 0x2c 0x30 0x30 0x2c 0x39 0x39 0x2e 0x39 0x39 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2a 0x35 0x36 0x0d 0x0a 0x24 0x47 0x4e 0x47 0x53 0x41 0x2c 0x41 0x2c 0x31 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x39 0x39 0x2e 0x39 0x39 0x2c 0x39 0x39 0x2e 0x39 0x39 0x2c 0x39 0x39 0x2e 0x39 0x39 0x2c 0x31 0x2a 0x33 0x33 0x0d 0x0a 0x24 0x47 0x4e 0x47 0x53 0x41 0x2c 0x41 0x2c 0x31 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x39 0x39 0x2e 0x39 0x39 0x2c 0x39 0x39 0x2e 0x39 0x39 0x2c 0x39 0x39 0x2e 0x39 0x39 0x2c 0x32 0x2a 0x33 0x30 0x0d 0x0a 0x24 0x47 0x4e 0x47 0x53 0x41 0x2c 0x41 0x2c 0x31 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x39 0x39 0x2e 0x39 0x39 0x2c 0x39 0x39 0x2e 0x39 0x39 0x2c 0x39 0x39 0x2e 0x39 0x39 0x2c 0x33 0x2a 0x33 0x31 0x0d 0x0a 0x24 0x47 0x4e 0x47 0x53 0x41 0x2c 0x41 0x2c 0x31 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x39 0x39 0x2e 0x39 0x39 0x2c 0x39 0x39 0x2e 0x39 0x39 0x2c 0x39 0x39 0x2e 0x39 0x39 0x2c 0x34 0x2a 0x33 0x36 0x0d 0x0a 0x24 0x47 0x50 0x47 0x53 0x56 0x2c 0x31 0x2c 0x31 0x2c 0x30 0x30 0x2c 0x31 0x2a 0x36 0x34 0x0d 0x0a 0x24 0x47 0x4c 0x47 0x53 0x56 0x2c 0x31 0x2c 0x31 0x2c 0x30 0x30 0x2c 0x31 0x2a 0x37 0x38 0x0d 0x0a 0x24 0x47 0x41 0x47 0x53 0x56 0x2c 0x31 0x2c 0x31 0x2c 0x30 0x30 0x2c 0x37 0x2a 0x37 0x33 0x0d 0x0a 0x24 0x47 0x42 0x47 0x53 0x56 0x2c 0x31 0x2c 0x31 0x2c 0x30 0x30 0x2c 0x31 0x2a 0x37 0x36 0x0d 0x0a 0x24 0x47 0x4e 0x47 0x4c 0x4c 0x2c 0x2c 0x2c 0x2c 0x2c 0x2c 0x56 0x2c 0x4e 0x2a 0x37 0x41 0x0d 0x0a 0 100.0 ********** *********** **** 00/00/2000 00:00:00 245 ****** ****** ***** *** ******** ****** *** 369 0 0
-
RE: Unable to read data from GNSS Module with Core 2
Hello,
I struggle to get GPS data from the GNSS module to the Core2.
I'm using the demo code here:
https://github.com/m5stack/M5Module-GNSS/blob/main/examples/getPosition/getPosition.ino
with the following settings: Serial2.begin(38400, SERIAL_8N1, 13, 14);it seems like the Core2 is receiving data from the module, but it doesn't catches any satellite.
The external antenna is connected and left outside.
I tried with another Core2 and another GNSS module with same result.Any idea ?
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1344
load:0x40078000,len:13964
load:0x40080400,len:3600
entry 0x400805f0Sats HDOP Latitude Longitude Fix Date Time Date Alt Course Speed Card Distance Course Card Chars Sentences Checksum
(deg) (deg) Age Age (m) --- from GPS ---- ---- to London ---- RX RX Fail**** ***** ********** *********** **** ********** ******** **** ****** ****** ***** *** ******** ****** *** 0 0 0
0 100.0 ********** *********** **** 00/00/2000 00:00:00 951 ****** ****** ***** *** ******** ****** *** 369 0 0
0 100.0 ********** *********** **** 00/00/2000 00:00:00 952 ****** ****** ***** *** ******** ****** *** 738 0 0
0 100.0 ********** *********** **** 00/00/2000 00:00:00 953 ****** ****** ***** *** ******** ****** *** 1107 0 0
....0 100.0 ********** *********** **** 00/00/2000 00:00:00 655 ****** ****** ***** *** ******** ****** *** 25400 0 0
0 100.0 ********** *********** **** 00/00/2000 00:00:00 656 ****** ****** ***** *** ******** ****** *** 25437 0 0
0 100.0 ********** *********** **** 00/00/2000 00:00:00 657 ****** ****** ***** *** ******** ****** *** 25474 0 0
0 100.0 ********** *********** **** 00/00/2000 00:00:00 657 ****** ****** ***** *** ******** ****** *** 25511 0 0 -
RE: M5Stack Core 2 External WiFi antenna
If you carefully look under the 3D antenna, you can see there are pre-soldered areas that look like for receiving an U.FL connector. Quite challenging to access to though. Maybe desolder the 3D antenna first.