Added onewire test

This commit is contained in:
c3ma 2021-01-30 19:27:27 +01:00
parent 1060166d43
commit f4f7195e4f
2 changed files with 18 additions and 1 deletions

View File

@ -14,3 +14,4 @@ board = esp32doit-devkit-v1
framework = arduino framework = arduino
build_flags = -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY build_flags = -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
lib_deps = OneWire lib_deps = OneWire
DallasTemperature

View File

@ -1,6 +1,7 @@
#include <Arduino.h> #include <Arduino.h>
#include "esp_sleep.h" #include "esp_sleep.h"
#include <DS18B20.h> #include <DS18B20.h>
#include "DallasTemperature.h"
#define uS_TO_S_FACTOR 1000000 /* Conversion factor for micro seconds to seconds */ #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) */ #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; int secondBootCount = 0;
Ds18B20 ds(SENSOR_DS18B20); Ds18B20 ds(SENSOR_DS18B20);
OneWire oneWire(SENSOR_DS18B20);
DallasTemperature sensors(&oneWire);
void print_wakeup_reason(){ void print_wakeup_reason(){
esp_sleep_wakeup_cause_t wakeup_reason; esp_sleep_wakeup_cause_t wakeup_reason;
@ -98,5 +102,17 @@ void setup() {
void loop() { void loop() {
Serial.println("test"); Serial.println("test");
delay(200); 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());
} }