From dca13dfe44215340f61147822ca6497fee74a94f Mon Sep 17 00:00:00 2001 From: c3ma Date: Fri, 9 Oct 2020 19:29:28 +0200 Subject: [PATCH] Debugging board --- esp32test/Esp32DeepSleepTest/platformio.ini | 2 +- esp32test/Esp32DeepSleepTest/src/main.cpp | 113 +++++++++++++------- 2 files changed, 77 insertions(+), 38 deletions(-) diff --git a/esp32test/Esp32DeepSleepTest/platformio.ini b/esp32test/Esp32DeepSleepTest/platformio.ini index e0a6037..768aa93 100644 --- a/esp32test/Esp32DeepSleepTest/platformio.ini +++ b/esp32test/Esp32DeepSleepTest/platformio.ini @@ -12,4 +12,4 @@ platform = espressif32 board = esp32doit-devkit-v1 framework = arduino -build_flags = -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY \ No newline at end of file +build_flags = -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY diff --git a/esp32test/Esp32DeepSleepTest/src/main.cpp b/esp32test/Esp32DeepSleepTest/src/main.cpp index fd5ee8b..246e2a8 100644 --- a/esp32test/Esp32DeepSleepTest/src/main.cpp +++ b/esp32test/Esp32DeepSleepTest/src/main.cpp @@ -4,6 +4,18 @@ #define uS_TO_S_FACTOR 1000000 /* Conversion factor for micro seconds to seconds */ #define TIME_TO_SLEEP 2 /* Time ESP32 will go to sleep (in seconds) */ +#define OUTPUT_PUMP0 23 /**< GPIO 23 */ +#define OUTPUT_PUMP1 22 /**< GPIO 22 */ +#define OUTPUT_PUMP2 21 /**< GPIO 21 */ +#define OUTPUT_PUMP3 19 /**< GPIO 19 */ +#define OUTPUT_PUMP4 18 /**< GPIO 18 */ +#define OUTPUT_PUMP5 5 /**< GPIO 5 */ +#define OUTPUT_PUMP6 15 /**< GPIO 15 */ + +#define OUTPUT_SENSOR 16 /**< GPIO 16 - Enable Sensors */ +#define OUTPUT_PUMP 13 /**< GPIO 13 - Enable Pumps */ + + RTC_DATA_ATTR int bootCount = 0; int secondBootCount = 0; @@ -22,25 +34,31 @@ void print_wakeup_reason(){ } } +void setAll2Off() { + digitalWrite(OUTPUT_PUMP0, LOW); + digitalWrite(OUTPUT_PUMP1, LOW); + digitalWrite(OUTPUT_PUMP2, LOW); + digitalWrite(OUTPUT_PUMP3, LOW); + digitalWrite(OUTPUT_PUMP4, LOW); + digitalWrite(OUTPUT_PUMP5, LOW); + digitalWrite(OUTPUT_PUMP6, LOW); + digitalWrite(OUTPUT_SENSOR, LOW); + digitalWrite(OUTPUT_PUMP, LOW); +} + void setup() { - pinMode(GPIO_NUM_23, OUTPUT); - pinMode(GPIO_NUM_22, OUTPUT); - pinMode(GPIO_NUM_21, OUTPUT); - pinMode(GPIO_NUM_19, OUTPUT); - pinMode(GPIO_NUM_18, OUTPUT); - pinMode(GPIO_NUM_5, OUTPUT); - pinMode(GPIO_NUM_4, OUTPUT); - pinMode(GPIO_NUM_15, OUTPUT); - pinMode(GPIO_NUM_13, OUTPUT); - digitalWrite(GPIO_NUM_23, HIGH); - digitalWrite(GPIO_NUM_22, HIGH); - digitalWrite(GPIO_NUM_21, HIGH); - digitalWrite(GPIO_NUM_19, HIGH); - digitalWrite(GPIO_NUM_18, HIGH); - digitalWrite(GPIO_NUM_5, HIGH); - digitalWrite(GPIO_NUM_4, HIGH); - digitalWrite(GPIO_NUM_15, HIGH); - digitalWrite(GPIO_NUM_13, HIGH); + pinMode(OUTPUT_PUMP0, OUTPUT); + pinMode(OUTPUT_PUMP1, OUTPUT); + pinMode(OUTPUT_PUMP2, OUTPUT); + pinMode(OUTPUT_PUMP3, OUTPUT); + pinMode(OUTPUT_PUMP4, OUTPUT); + pinMode(OUTPUT_PUMP5, OUTPUT); + pinMode(OUTPUT_PUMP6, OUTPUT); + pinMode(OUTPUT_SENSOR, OUTPUT); + pinMode(OUTPUT_PUMP, OUTPUT); + + setAll2Off(); + Serial.begin(115200); //Increment boot number and print it every reboot @@ -77,31 +95,52 @@ void setup() { pinMode(GPIO_NUM_12, INPUT_PULLUP); } + + void loop() { Serial.println("------------"); Serial.flush(); delay(1000); digitalWrite(GPIO_NUM_23, analogRead(GPIO_NUM_34) > 3500); - Serial.println(analogRead(GPIO_NUM_34)); - - Serial.println(analogRead(GPIO_NUM_35)); - - Serial.println(analogRead(GPIO_NUM_32)); - - Serial.println(analogRead(GPIO_NUM_33)); - - Serial.println(analogRead(GPIO_NUM_25)); - - Serial.println(analogRead(GPIO_NUM_26)); - - Serial.println(analogRead(GPIO_NUM_27)); - Serial.println(analogRead(GPIO_NUM_14)); - Serial.println(analogRead(GPIO_NUM_12)); - - gpio_hold_en(GPIO_NUM_4); - gpio_hold_en(GPIO_NUM_13); - gpio_hold_en(GPIO_NUM_15); + digitalWrite(OUTPUT_PUMP0, HIGH); + delay(1000); + setAll2Off(); + + digitalWrite(OUTPUT_PUMP1, HIGH); + delay(1000); + setAll2Off(); + + digitalWrite(OUTPUT_PUMP2, HIGH); + delay(1000); + setAll2Off(); + + digitalWrite(OUTPUT_PUMP3, HIGH); + delay(1000); + setAll2Off(); + + digitalWrite(OUTPUT_PUMP4, HIGH); + delay(1000); + setAll2Off(); + + digitalWrite(OUTPUT_PUMP5, HIGH); + delay(1000); + setAll2Off(); + + digitalWrite(OUTPUT_PUMP6, HIGH); + delay(1000); + setAll2Off(); + + digitalWrite(OUTPUT_SENSOR, HIGH); + delay(1000); + setAll2Off(); + + digitalWrite(OUTPUT_PUMP, HIGH); + delay(1000); + setAll2Off(); + + delay(1000); + delay(1000); gpio_deep_sleep_hold_en(); esp_deep_sleep_start();