-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create bbn_m5atomS3_lite_DS18B20.ino
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |