Skip to content

Commit

Permalink
Update bbn_m5atomS3_lite_env.ino
Browse files Browse the repository at this point in the history
  • Loading branch information
mgrouch authored Nov 6, 2024
1 parent 99ecdbb commit 978c582
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions bbn_m5atomS3_lite_env/bbn_m5atomS3_lite_env.ino
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include <M5AtomS3.h>
#include <Arduino.h>
#include <M5UnitENV.h>
#include <Wire.h>
#include "NmeaXDR.h"
#include "Nmea0183Msg.h"

SHT3X sht3x;
QMP6988 qmp6988;
DHT12 dht12;
BMP280 bmp280;

void setup() {
auto cfg = M5.config();
Expand All @@ -14,27 +14,34 @@ void setup() {
Serial.begin(4800);

int i = 0;
while (!qmp6988.begin(&Wire, QMP6988_SLAVE_ADDRESS_L, G2, G1, 100000U) && i < 3) {
gen_nmea0183_msg("$BBTXT,01,01,01,Sensor not found type=%s", "QMP6988");
while (!dht12.begin(&Wire, DHT12_I2C_ADDR, G2, G1, 100000U) && i < 3) {
gen_nmea0183_msg("$BBTXT,01,01,01,Sensor not found type=%s", "DHT12");
delay(4);
i++;
}
i = 0;
while (!sht3x.begin(&Wire, SHT3X_I2C_ADDR, G2, G1, 100000U) && i < 3) {
gen_nmea0183_msg("$BBTXT,01,01,01,Sensor not found type=%s", "SHT3X");
while (!bmp280.begin(&Wire, BMP280_I2C_ADDR, G2, G1, 100000U) && i < 3) {
gen_nmea0183_msg("$BBTXT,01,01,01,Sensor not found type=%s", "BMP280");
delay(4);
i++;
}

/* Default settings from datasheet. */
bmp.setSampling(BMP280::MODE_NORMAL, /* Operating Mode. */
BMP280::SAMPLING_X2, /* Temp. oversampling */
BMP280::SAMPLING_X16, /* Pressure oversampling */
BMP280::FILTER_X16, /* Filtering. */
BMP280::STANDBY_MS_500); /* Standby time. */
}

void loop() {
if (sht3x.update()) {
gen_nmea0183_xdr("$BBXDR,H,%.2f,P,HUMI_SHT3X", sht3x.humidity); // %
gen_nmea0183_xdr("$BBXDR,C,%.2f,C,TEMP_SHT3X", sht3x.cTemp); // C
if (dht12.update()) {
gen_nmea0183_xdr("$BBXDR,H,%.2f,P,HUMI_DHT12", dht12.humidity); // %
gen_nmea0183_xdr("$BBXDR,C,%.2f,C,TEMP_DHT12", dht12.cTemp); // C
}
if (qmp6988.update()) {
gen_nmea0183_xdr("$BBXDR,C,%.2f,C,TEMP_QMP6988", qmp6988.cTemp); // C
gen_nmea0183_xdr("$BBXDR,P,%.2f,P,PRES_QMP6988", qmp6988.pressure); // Pa
if (bmp280.update()) {
gen_nmea0183_xdr("$BBXDR,C,%.2f,C,TEMP_BMP280", bmp280.cTemp); // C
gen_nmea0183_xdr("$BBXDR,P,%.2f,P,PRES_BMP280", bmp280.pressure); // Pa
}
delay(1000);
}

0 comments on commit 978c582

Please sign in to comment.