From 3a2ddb92e360ea09063da8b96e7824cd29bac027 Mon Sep 17 00:00:00 2001 From: Ollo Date: Wed, 22 Mar 2023 20:06:35 +0100 Subject: [PATCH] Set onewire bus --- esp32test/Esp32DeepSleepTest/src/main.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/esp32test/Esp32DeepSleepTest/src/main.cpp b/esp32test/Esp32DeepSleepTest/src/main.cpp index bea0eec..fa2de84 100644 --- a/esp32test/Esp32DeepSleepTest/src/main.cpp +++ b/esp32test/Esp32DeepSleepTest/src/main.cpp @@ -2,6 +2,9 @@ #include "driver/pcnt.h" #include +#define SENSOR_TANK_SDA GPIO_NUM_16 /**< GPIO 16 - echo feedback of water sensor */ +#define SENSOR_TANK_SCL GPIO_NUM_17 /**< GPIO 17 - trigger for water sensor */ + #define OUTPUT_SENSOR 14 #define SENSOR_PLANT 17 @@ -18,6 +21,10 @@ void setup() Serial.println("Nodemcu ESP32 Start done"); tankSensor.setTimeout(500); + Wire.begin(SENSOR_TANK_SDA, SENSOR_TANK_SCL, 100000UL /* 100kHz */); + tankSensor.setTimeout(500); + tankSensor.setBus(&Wire); + delay(20); long start = millis(); bool distanceReady = false; while (start + 500 > millis())