From 1c2b6241c6b01c4e4bd8a56959313f2b711456e6 Mon Sep 17 00:00:00 2001 From: Mikhail Grushinskiy Date: Wed, 23 Oct 2024 19:58:01 -0400 Subject: [PATCH] Create bbn_m5atomS3_lite_DS18B20.ino --- .../bbn_m5atomS3_lite_DS18B20.ino | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 bbn_m5atomS3_lite_DS18B20/bbn_m5atomS3_lite_DS18B20.ino diff --git a/bbn_m5atomS3_lite_DS18B20/bbn_m5atomS3_lite_DS18B20.ino b/bbn_m5atomS3_lite_DS18B20/bbn_m5atomS3_lite_DS18B20.ino new file mode 100644 index 0000000..d39d590 --- /dev/null +++ b/bbn_m5atomS3_lite_DS18B20/bbn_m5atomS3_lite_DS18B20.ino @@ -0,0 +1,28 @@ +#include +#include +#include +#include + +#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); +}