From 978c5826ba904fe664842a7c5b5c4ff4650fd599 Mon Sep 17 00:00:00 2001 From: Mikhail Grushinskiy Date: Tue, 5 Nov 2024 20:30:39 -0500 Subject: [PATCH] Update bbn_m5atomS3_lite_env.ino --- .../bbn_m5atomS3_lite_env.ino | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/bbn_m5atomS3_lite_env/bbn_m5atomS3_lite_env.ino b/bbn_m5atomS3_lite_env/bbn_m5atomS3_lite_env.ino index 116ac0a..b976b3b 100644 --- a/bbn_m5atomS3_lite_env/bbn_m5atomS3_lite_env.ino +++ b/bbn_m5atomS3_lite_env/bbn_m5atomS3_lite_env.ino @@ -1,11 +1,11 @@ #include +#include #include #include #include "NmeaXDR.h" -#include "Nmea0183Msg.h" -SHT3X sht3x; -QMP6988 qmp6988; +DHT12 dht12; +BMP280 bmp280; void setup() { auto cfg = M5.config(); @@ -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); }