Skip to content

Commit

Permalink
Create bbn_m5atomS3_lite_DS18B20.ino
Browse files Browse the repository at this point in the history
  • Loading branch information
mgrouch authored Oct 23, 2024
1 parent d41a969 commit 1c2b624
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions bbn_m5atomS3_lite_DS18B20/bbn_m5atomS3_lite_DS18B20.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <M5AtomS3.h>
#include <M5Unified.h>
#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS G8
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

void setup() {
auto cfg = M5.config();
AtomS3.begin(cfg);
Serial.begin(4800);
sensors.begin();
int count = sensors.getDeviceCount();
Serial.printf("Sensors found %d\n", count);
}

void loop() {
int count = sensors.getDeviceCount();
if (count > 0) {
sensors.requestTemperatures();
for (int i = 0; i < count; i++) {
Serial.printf("Temp %.2f\n", sensors.getTempCByIndex(i));
}
}
delay(1000);
}

0 comments on commit 1c2b624

Please sign in to comment.