Skip to content

Commit 27cd76d

Browse files
committed
init
1 parent 7d60f75 commit 27cd76d

32 files changed

+35522
-45
lines changed

.github/workflows/Arduino-Lint-Check.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
name: Arduino Lint Check
22
on:
33
push:
4-
branches: [ master ]
54
pull_request:
6-
branches: [ master ]
75
jobs:
86
lint:
97
name: Lint Check

.github/workflows/clang-format-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
matrix:
99
path:
1010
- check: './' # path to include
11-
exclude: '' # path to exclude
11+
exclude: 'src' # path to exclude
1212
# - check: 'src'
1313
# exclude: '(Fonts)' # Exclude file paths containing "Fonts"
1414
# - check: 'examples'

README.md

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,10 @@
1-
# Product Name
1+
# M5Module-GNSS
22

3-
## Overview
3+
[![Arduino Lint](https://github.com/m5stack/M5Module-GNSS/actions/workflows/Arduino-Lint-Check.yml/badge.svg)](https://github.com/m5stack/M5Module-GNSS/actions/workflows/Arduino-Lint-Check.yml)
4+
[![Clang Format](https://github.com/m5stack/M5Module-GNSS/actions/workflows/clang-format-check.yml/badge.svg)](https://github.com/m5stack/M5Module-GNSS/actions/workflows/clang-format-check.yml)
45

5-
### SKU:xxx
6-
7-
Description of the product
8-
9-
## Related Link
10-
11-
- [Document & Datasheet](https://docs.m5stack.com/en/unit/product_Link)
12-
13-
## Required Libraries:
14-
15-
- [Adafruit_BMP280_Library](https://github.com/adafruit/Required_Libraries_Link)
166

177
## License
188

19-
- [Product Name- MIT](LICENSE)
20-
21-
## Remaining steps(Editorial Staff Look,After following the steps, remember to delete all the content below)
22-
23-
1. Change [clang format check path](./.github/workflows/clang-format-check.yml#L9-L15).
24-
2. Add License content to [LICENSE](/LICENSE).
25-
3. Change link on line 78 of [bug-report.yml](./.github/ISSUE_TEMPLATE/bug-report.yml#L78).
26-
27-
```cpp
28-
Example
29-
# M5Unit-ENV
30-
31-
## Overview
32-
33-
### SKU:U001 & U001-B & U001-C
34-
35-
Contains M5Stack-**UNIT ENV** series related case programs.ENV is an environmental sensor with integrated SHT30 and QMP6988 internally to detect temperature, humidity, and atmospheric pressure data.
36-
37-
## Related Link
38-
39-
- [Document & Datasheet](https://docs.m5stack.com/en/unit/envIII)
40-
41-
## Required Libraries:
42-
43-
- [Adafruit_BMP280_Library](https://github.com/adafruit/Adafruit_BMP280_Library)
44-
45-
## License
9+
- [M5Module-GNSS - MIT](LICENSE)
4610

47-
- [M5Unit-ENV - MIT](LICENSE)
48-
```
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
/**
2+
* @file getSensorData.ino
3+
* @author SeanKwok (shaoxiang@m5stack.com)
4+
* @brief M5Module GNSS Get Possition Demo.
5+
* @version 0.1
6+
* @date 2023-08-31
7+
*
8+
*
9+
* @Hardwares:M5Module GNSS
10+
* @Platform Version: Arduino M5Stack Board Manager v2.0.7
11+
* @Dependent Library:
12+
* TinyGPSPlus: https://github.com/mikalhart/TinyGPSPlus
13+
*/
14+
15+
#include <TinyGPSPlus.h>
16+
17+
TinyGPSPlus gps;
18+
19+
static void smartDelay(unsigned long ms);
20+
static void printFloat(float val, bool valid, int len, int prec);
21+
static void printInt(unsigned long val, bool valid, int len);
22+
static void printDateTime(TinyGPSDate &d, TinyGPSTime &t);
23+
static void printStr(const char *str, int len);
24+
25+
void setup() {
26+
Serial.begin(115200);
27+
Serial2.begin(115200, SERIAL_8N1, 16, 17);
28+
29+
Serial.println();
30+
Serial.println(F(
31+
"Sats HDOP Latitude Longitude Fix Date Time Date Alt "
32+
" Course Speed Card Distance Course Card Chars Sentences Checksum"));
33+
Serial.println(
34+
F(" (deg) (deg) Age Age (m) "
35+
" --- from GPS ---- ---- to London ---- RX RX Fail"));
36+
Serial.println(F(
37+
"----------------------------------------------------------------------"
38+
"------------------------------------------------------------------"));
39+
}
40+
41+
void loop() {
42+
static const double LONDON_LAT = 51.508131, LONDON_LON = -0.128002;
43+
44+
printInt(gps.satellites.value(), gps.satellites.isValid(), 5);
45+
printFloat(gps.hdop.hdop(), gps.hdop.isValid(), 6, 1);
46+
printFloat(gps.location.lat(), gps.location.isValid(), 11, 6);
47+
printFloat(gps.location.lng(), gps.location.isValid(), 12, 6);
48+
printInt(gps.location.age(), gps.location.isValid(), 5);
49+
printDateTime(gps.date, gps.time);
50+
printFloat(gps.altitude.meters(), gps.altitude.isValid(), 7, 2);
51+
printFloat(gps.course.deg(), gps.course.isValid(), 7, 2);
52+
printFloat(gps.speed.kmph(), gps.speed.isValid(), 6, 2);
53+
printStr(
54+
gps.course.isValid() ? TinyGPSPlus::cardinal(gps.course.deg()) : "*** ",
55+
6);
56+
57+
unsigned long distanceKmToLondon =
58+
(unsigned long)TinyGPSPlus::distanceBetween(
59+
gps.location.lat(), gps.location.lng(), LONDON_LAT, LONDON_LON) /
60+
1000;
61+
printInt(distanceKmToLondon, gps.location.isValid(), 9);
62+
63+
double courseToLondon = TinyGPSPlus::courseTo(
64+
gps.location.lat(), gps.location.lng(), LONDON_LAT, LONDON_LON);
65+
66+
printFloat(courseToLondon, gps.location.isValid(), 7, 2);
67+
68+
const char *cardinalToLondon = TinyGPSPlus::cardinal(courseToLondon);
69+
70+
printStr(gps.location.isValid() ? cardinalToLondon : "*** ", 6);
71+
72+
printInt(gps.charsProcessed(), true, 6);
73+
printInt(gps.sentencesWithFix(), true, 10);
74+
printInt(gps.failedChecksum(), true, 9);
75+
Serial.println();
76+
77+
smartDelay(1000);
78+
79+
if (millis() > 5000 && gps.charsProcessed() < 10)
80+
Serial.println(F("No GPS data received: check wiring"));
81+
}
82+
83+
// This custom version of delay() ensures that the gps object
84+
// is being "fed".
85+
static void smartDelay(unsigned long ms) {
86+
unsigned long start = millis();
87+
do {
88+
while (Serial2.available()) gps.encode(Serial2.read());
89+
} while (millis() - start < ms);
90+
}
91+
92+
static void printFloat(float val, bool valid, int len, int prec) {
93+
if (!valid) {
94+
while (len-- > 1) Serial.print('*');
95+
Serial.print(' ');
96+
} else {
97+
Serial.print(val, prec);
98+
int vi = abs((int)val);
99+
int flen = prec + (val < 0.0 ? 2 : 1); // . and -
100+
flen += vi >= 1000 ? 4 : vi >= 100 ? 3 : vi >= 10 ? 2 : 1;
101+
for (int i = flen; i < len; ++i) Serial.print(' ');
102+
}
103+
smartDelay(0);
104+
}
105+
106+
static void printInt(unsigned long val, bool valid, int len) {
107+
char sz[32] = "*****************";
108+
if (valid) sprintf(sz, "%ld", val);
109+
sz[len] = 0;
110+
for (int i = strlen(sz); i < len; ++i) sz[i] = ' ';
111+
if (len > 0) sz[len - 1] = ' ';
112+
Serial.print(sz);
113+
smartDelay(0);
114+
}
115+
116+
static void printDateTime(TinyGPSDate &d, TinyGPSTime &t) {
117+
if (!d.isValid()) {
118+
Serial.print(F("********** "));
119+
} else {
120+
char sz[32];
121+
sprintf(sz, "%02d/%02d/%02d ", d.month(), d.day(), d.year());
122+
Serial.print(sz);
123+
}
124+
125+
if (!t.isValid()) {
126+
Serial.print(F("******** "));
127+
} else {
128+
char sz[32];
129+
sprintf(sz, "%02d:%02d:%02d ", t.hour(), t.minute(), t.second());
130+
Serial.print(sz);
131+
}
132+
133+
printInt(d.age(), d.isValid(), 5);
134+
smartDelay(0);
135+
}
136+
137+
static void printStr(const char *str, int len) {
138+
int slen = strlen(str);
139+
for (int i = 0; i < len; ++i) Serial.print(i < slen ? str[i] : ' ');
140+
smartDelay(0);
141+
}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
2+
/**
3+
* @file getSensorData.ino
4+
* @author SeanKwok (shaoxiang@m5stack.com)
5+
* @brief M5Module GNSS Get Sensor Data Demo.
6+
* @version 0.1
7+
* @date 2023-08-31
8+
*
9+
*
10+
* @Hardwares:M5Module GNSS
11+
* @Platform Version: Arduino M5Stack Board Manager v2.0.7
12+
* @Dependent Library:
13+
* M5Module_GNSS: https://github.com/m5stack/M5Module-GNSS
14+
* Adafruit BMP280 Library: https://github.com/adafruit/Adafruit_BMP280_Library
15+
*/
16+
17+
#include "M5Module_GNSS.h"
18+
#include <Adafruit_BMP280.h>
19+
20+
M5_BMI270_BMM150 bmi270_bmm150(&Wire);
21+
Adafruit_BMP280 bmp(&Wire);
22+
23+
#define BIM270_SENSOR_ADDR 0x68
24+
#define BMM150_SENSOR_ADDR 0x10
25+
#define BMP280_SENSOR_ADDR 0x76
26+
27+
void setup() {
28+
// put your setup code here, to run once:
29+
30+
Serial.begin(115200);
31+
Wire.begin(21, 22, 100000);
32+
while (!Serial)
33+
;
34+
35+
unsigned status;
36+
37+
status = bmp.begin(BMP280_SENSOR_ADDR);
38+
if (!status) {
39+
Serial.println(
40+
F("Could not find a valid BMP280 sensor, check wiring or "
41+
"try a different address!"));
42+
Serial.print("SensorID was: 0x");
43+
Serial.println(bmp.sensorID(), 16);
44+
while (1) delay(10);
45+
}
46+
47+
bmi270_bmm150.debug(Serial);
48+
status = bmi270_bmm150.begin(BIM270_SENSOR_ADDR, BMM150_SENSOR_ADDR);
49+
if (!status) {
50+
Serial.println("sensor init error");
51+
while (1) delay(10);
52+
};
53+
54+
Serial.print("Accelerometer sample rate = ");
55+
Serial.println(bmi270_bmm150.accelerationSampleRate());
56+
}
57+
58+
void loop() {
59+
// put your main code here, to run repeatedly:
60+
float x, y, z;
61+
62+
if (bmi270_bmm150.accelerationAvailable()) {
63+
bmi270_bmm150.readAcceleration(x, y, z);
64+
65+
Serial.print("accel: \t");
66+
Serial.print(x);
67+
Serial.print('\t');
68+
Serial.print(y);
69+
Serial.print('\t');
70+
Serial.print(z);
71+
Serial.println();
72+
}
73+
74+
if (bmi270_bmm150.gyroscopeAvailable()) {
75+
bmi270_bmm150.readGyroscope(x, y, z);
76+
77+
Serial.print("gyro: \t");
78+
Serial.print(x);
79+
Serial.print('\t');
80+
Serial.print(y);
81+
Serial.print('\t');
82+
Serial.print(z);
83+
Serial.println();
84+
}
85+
86+
if (bmi270_bmm150.magneticFieldAvailable()) {
87+
bmi270_bmm150.readMagneticField(x, y, z);
88+
89+
Serial.print("mag: \t");
90+
Serial.print(x);
91+
Serial.print('\t');
92+
Serial.print(y);
93+
Serial.print('\t');
94+
Serial.print(z);
95+
Serial.println();
96+
}
97+
98+
Serial.print(F("Temperature = "));
99+
Serial.print(bmp.readTemperature());
100+
Serial.println(" *C");
101+
102+
Serial.print(F("Pressure = "));
103+
Serial.print(bmp.readPressure());
104+
Serial.println(" Pa");
105+
106+
Serial.print(F("Approx altitude = "));
107+
Serial.print(bmp.readAltitude(1013.25)); /* Adjusted to local forecast! */
108+
Serial.println(" m");
109+
110+
Serial.println();
111+
delay(500);
112+
}

library.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "M5Module-GNSS",
3+
"description": "Library for M5Stack GNSS Module",
4+
"keywords": "M5Stack",
5+
"authors": {
6+
"name": "M5Stack",
7+
"url": "http://www.m5stack.com"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "https://github.com/m5stack/M5Module-GNSS.git"
12+
},
13+
"version": "1.0.0",
14+
"frameworks": "arduino",
15+
"platforms": "espressif32",
16+
"headers": "M5Module_GNSS.h"
17+
}

library.properties

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name=M5Module-GNSS
2+
version=1.0.0
3+
author=M5Stack
4+
maintainer=M5Stack
5+
sentence=Library for M5Stack GNSS Module
6+
paragraph=See more on http://M5Stack.com
7+
category=Device Control
8+
url=https://github.com/m5stack/M5Module-GNSS
9+
architectures=esp32
10+
includes=M5Module_GNSS.h
11+
depends=TinyGPSPlus,Adafruit BMP280 Library,Adafruit Unified Sensor,Adafruit BusIO

src/M5Module_GNSS.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#ifndef _M5_MODULE_GNSS_H
2+
#define _M5_MODULE_GNSS_H
3+
4+
#include <Arduino.h>
5+
#include <Wire.h>
6+
7+
#include "M5_BMI270_BMM150.h"
8+
9+
#endif

0 commit comments

Comments
 (0)