Skip to content

Commit

Permalink
Create bbn_m5atomS3_lite_env.ino
Browse files Browse the repository at this point in the history
  • Loading branch information
mgrouch authored Nov 5, 2024
1 parent 6736a8f commit 8824b5f
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions bbn_m5atomS3_lite_env/bbn_m5atomS3_lite_env.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include <M5AtomS3.h>
#include <Arduino.h>
#include <M5UnitENV.h>
#include <Wire.h>
#include "NmeaXDR.h"

DHT12 dht;
BMP280 bmp;

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

if (!dht.begin(&Wire, DHT12_I2C_ADDR, G2, G1, 100000U)) {
Serial.println("Couldn't find DHT12");
while (1) delay(1);
}

if (!bmp.begin(&Wire, BMP280_I2C_ADDR, G2, G1, 100000U)) {
Serial.println("Couldn't find BMP280");
while (1) delay(1);
}

/* 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 (dht.update()) {
gen_nmea0183_xdr("$BBXDR,H,%.2f,P,HUMI_DHT12", dht.humidity); // %
gen_nmea0183_xdr("$BBXDR,C,%.2f,C,TEMP_DHT12", dht.cTemp); // C
}

if (bmp.update()) {
gen_nmea0183_xdr("$BBXDR,C,%.2f,C,TEMP_BMP280", bmp.cTemp); // C
gen_nmea0183_xdr("$BBXDR,P,%.2f,P,PRES_BMP280", bmp.pressure); // Pa
}
delay(1000);
}

0 comments on commit 8824b5f

Please sign in to comment.