Skip to content

Commit

Permalink
Update bbn_m5atomS3_lite_env3.ino
Browse files Browse the repository at this point in the history
  • Loading branch information
mgrouch authored Nov 6, 2024
1 parent 84c86e8 commit 97969e8
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions bbn_m5atomS3_lite_env3/bbn_m5atomS3_lite_env3.ino
Original file line number Diff line number Diff line change
@@ -1,39 +1,35 @@
#include <M5AtomS3.h>
#include <M5Unified.h>
#include <Arduino.h>
#include <M5UnitENV.h>
#include <Wire.h>
#include "NmeaXDR.h"
#include "Nmea0183Msg.h"

SHT3X sht3x;
QMP6988 qmp;
QMP6988 qmp6988;

void setup() {
auto cfg = M5.config();
AtomS3.begin(cfg);
Wire.begin();
Serial.begin(4800);

if (!qmp.begin(&Wire, QMP6988_SLAVE_ADDRESS_L, G2, G1, 100000U)) {
Serial.println("Couldn't find QMP6988");
while (1) delay(1);

if (!qmp6988.begin(&Wire, QMP6988_SLAVE_ADDRESS_L, G2, G1, 100000U)) {
gen_nmea0183_msg("$BBTXT,01,01,01,Sensor not found type=%s", "QMP6988");
}

if (!sht3x.begin(&Wire, SHT3X_I2C_ADDR, G2, G1, 100000U)) {
Serial.println("Couldn't find SHT3X");
while (1) delay(1);
gen_nmea0183_msg("$BBTXT,01,01,01,Sensor not found type=%s", "SHT3X");
}
}

void loop() {
if (sht3x.update()) {
gen_nmea0183_xdr("$BBXDR,H,%.2f,P,HUMI", sht3x.humidity); // %
//gen_nmea0183_xdr("$BBXDR,C,%.2f,C,TEMP", sht3x.cTemp); // C
gen_nmea0183_xdr("$BBXDR,H,%.2f,P,HUMI_SHT3X", sht3x.humidity); // %
gen_nmea0183_xdr("$BBXDR,C,%.2f,C,TEMP_SHT3X", sht3x.cTemp); // C
}

if (qmp.update()) {
gen_nmea0183_xdr("$BBXDR,C,%.2f,C,TEMP", qmp.cTemp); // C
gen_nmea0183_xdr("$BBXDR,P,%.2f,P,PRES", qmp.pressure); // Pa
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
}
delay(5000);
delay(1000);
}

0 comments on commit 97969e8

Please sign in to comment.