From f4f7195e4f59836465b1c033d16661d45b18094a Mon Sep 17 00:00:00 2001 From: c3ma Date: Sat, 30 Jan 2021 19:27:27 +0100 Subject: [PATCH] Added onewire test --- esp32test/Esp32DeepSleepTest/platformio.ini | 1 + esp32test/Esp32DeepSleepTest/src/main.cpp | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/esp32test/Esp32DeepSleepTest/platformio.ini b/esp32test/Esp32DeepSleepTest/platformio.ini index 27cb0c8..69e6ffc 100644 --- a/esp32test/Esp32DeepSleepTest/platformio.ini +++ b/esp32test/Esp32DeepSleepTest/platformio.ini @@ -14,3 +14,4 @@ board = esp32doit-devkit-v1 framework = arduino build_flags = -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY lib_deps = OneWire + DallasTemperature diff --git a/esp32test/Esp32DeepSleepTest/src/main.cpp b/esp32test/Esp32DeepSleepTest/src/main.cpp index 8876f8c..81db9b6 100644 --- a/esp32test/Esp32DeepSleepTest/src/main.cpp +++ b/esp32test/Esp32DeepSleepTest/src/main.cpp @@ -1,6 +1,7 @@ #include #include "esp_sleep.h" #include +#include "DallasTemperature.h" #define uS_TO_S_FACTOR 1000000 /* Conversion factor for micro seconds to seconds */ #define TIME_TO_SLEEP 5 /* Time ESP32 will go to sleep (in seconds) */ @@ -34,6 +35,9 @@ RTC_DATA_ATTR int pumpActive = 0; int secondBootCount = 0; Ds18B20 ds(SENSOR_DS18B20); +OneWire oneWire(SENSOR_DS18B20); +DallasTemperature sensors(&oneWire); + void print_wakeup_reason(){ esp_sleep_wakeup_cause_t wakeup_reason; @@ -98,5 +102,17 @@ void setup() { void loop() { Serial.println("test"); delay(200); - + digitalWrite(OUTPUT_PUMP0, HIGH); + + sensors.begin(); + + for(int j=0; j < 5 && sensors.getDeviceCount() == 0; j++) { + delay(100); + sensors.begin(); + Serial.println("Reset 1wire"); + } + + Serial.println(sensors.getDeviceCount()); + + } \ No newline at end of file