Skip to content

Commit

Permalink
Update bbn_m5atomS3_lite_WOX_BME680.ino
Browse files Browse the repository at this point in the history
  • Loading branch information
mgrouch authored Nov 6, 2024
1 parent bb35eb1 commit 90139bd
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions bbn_m5atomS3_lite_WOX_BME680/bbn_m5atomS3_lite_WOX_BME680.ino
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
#include <Adafruit_Sensor.h>
#include <Adafruit_BME680.h>
#include "NmeaXDR.h"
#include "NmeaChecksum.h"
#include "Nmea0183Msg.h"

#define SEALEVELPRESSURE_HPA (1013.25)

Adafruit_BME680 bme(&Wire); // I2C
Adafruit_BME680 bme680(&Wire); // I2C

void setup() {
auto cfg = M5.config();
Expand All @@ -16,23 +16,28 @@ void setup() {
Wire.setClock(100000);
delay(10);
Serial.begin(4800);
while (!bme.begin()) {}
int i = 0;
while (!bme680.begin() && i < 3) {
gen_nmea0183_msg("$BBTXT,01,01,01,Sensor not found type=%s", "BME680");
delay(4);
i++;
}
// Set up oversampling and filter initialization
bme.setTemperatureOversampling(BME680_OS_8X);
bme.setHumidityOversampling(BME680_OS_2X);
bme.setPressureOversampling(BME680_OS_4X);
bme.setIIRFilterSize(BME680_FILTER_SIZE_3);
bme.setGasHeater(320, 150); // 320*C for 150 ms
bme680.setTemperatureOversampling(BME680_OS_8X);
bme680.setHumidityOversampling(BME680_OS_2X);
bme680.setPressureOversampling(BME680_OS_4X);
bme680.setIIRFilterSize(BME680_FILTER_SIZE_3);
bme680.setGasHeater(320, 150); // 320*C for 150 ms
}

void loop() {
if (!bme.performReading()) {
if (!bme680.performReading()) {
delay(4);
return;
}
gen_nmea0183_xdr("$BBXDR,C,%.2f,C,TEMP_BME680", bme.temperature); // C
gen_nmea0183_xdr("$BBXDR,P,%.2f,P,PRES_BME680", bme.pressure); // Pa
gen_nmea0183_xdr("$BBXDR,H,%.2f,P,HUMI_BME680", bme.humidity); // %
gen_nmea0183_xdr("$BBXDR,H,%.2f,,GASR_BME680", bme.gas_resistance / 1000.0); // KOhms
gen_nmea0183_xdr("$BBXDR,C,%.2f,C,TEMP_BME680", bme680.temperature); // C
gen_nmea0183_xdr("$BBXDR,P,%.2f,P,PRES_BME680", bme680.pressure); // Pa
gen_nmea0183_xdr("$BBXDR,H,%.2f,P,HUMI_BME680", bme680.humidity); // %
gen_nmea0183_xdr("$BBXDR,H,%.2f,,GASR_BME680", bme680.gas_resistance / 1000.0); // KOhms
delay(5000);
}

0 comments on commit 90139bd

Please sign in to comment.