diff options
| author | opekk <maciek09874@gmail.com> | 2026-05-21 23:37:01 +0200 |
|---|---|---|
| committer | opekk <maciek09874@gmail.com> | 2026-05-21 23:37:01 +0200 |
| commit | 52a456d6a36d48e09033a48d64c66673bb19c754 (patch) | |
| tree | e49d56372e3b687e62a81169fba74e35ec1e4ddc | |
| parent | 70dd357e2841bed77d37316833881bfb72cf60f0 (diff) | |
feat: add function to read all sensors
| -rw-r--r-- | src/main.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp index ef8a702..ca4efb7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,7 +7,8 @@ #include <SPI.h> #include <ESP32Servo.h> #include <ezButton.h> - +#include <OneWire.h> +#include <DallasTemperature.h> /* todo * pobierac temp z onewire (wybierz jakes piny) i aktualizowac w loopie co np 10 sekund. @@ -28,6 +29,12 @@ Adafruit_ST7789 tft = Adafruit_ST7789(&SPI, TFT_CS, TFT_DC, TFT_RST); Servo myServo; +OneWire oneWire(ONE_WIRE_BUS); +DallasTemperature sensors(&oneWire); + + +float tempInternal; +float tempCurrent; float temp_min_internal; float temp_max_external; @@ -35,6 +42,24 @@ float temp_max_external; float temp_cur_internal; float temp_cur_external; +int deviceCount = 0; + +void setupSensors(){ + sensors.begin(115200); // baud rate + + Serial.print("Searching for devices.") + deviceCount = sensors.getDeviceCount(); + + if(deviceCount != 0) { + Serial.print(deviceCount, DEC); + } + + else { + Serial.print("Cannot find any devices connected to One_Wire_Bus"); + } + +} + void setupDisplay(){ |