Debugging board

This commit is contained in:
c3ma 2020-10-09 19:29:28 +02:00
parent a16c98d7c6
commit dca13dfe44
2 changed files with 77 additions and 38 deletions

View File

@ -12,4 +12,4 @@
platform = espressif32 platform = espressif32
board = esp32doit-devkit-v1 board = esp32doit-devkit-v1
framework = arduino framework = arduino
build_flags = -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY build_flags = -DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY

View File

@ -4,6 +4,18 @@
#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 2 /* Time ESP32 will go to sleep (in 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; RTC_DATA_ATTR int bootCount = 0;
int secondBootCount = 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() { void setup() {
pinMode(GPIO_NUM_23, OUTPUT); pinMode(OUTPUT_PUMP0, OUTPUT);
pinMode(GPIO_NUM_22, OUTPUT); pinMode(OUTPUT_PUMP1, OUTPUT);
pinMode(GPIO_NUM_21, OUTPUT); pinMode(OUTPUT_PUMP2, OUTPUT);
pinMode(GPIO_NUM_19, OUTPUT); pinMode(OUTPUT_PUMP3, OUTPUT);
pinMode(GPIO_NUM_18, OUTPUT); pinMode(OUTPUT_PUMP4, OUTPUT);
pinMode(GPIO_NUM_5, OUTPUT); pinMode(OUTPUT_PUMP5, OUTPUT);
pinMode(GPIO_NUM_4, OUTPUT); pinMode(OUTPUT_PUMP6, OUTPUT);
pinMode(GPIO_NUM_15, OUTPUT); pinMode(OUTPUT_SENSOR, OUTPUT);
pinMode(GPIO_NUM_13, OUTPUT); pinMode(OUTPUT_PUMP, OUTPUT);
digitalWrite(GPIO_NUM_23, HIGH);
digitalWrite(GPIO_NUM_22, HIGH); setAll2Off();
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);
Serial.begin(115200); Serial.begin(115200);
//Increment boot number and print it every reboot //Increment boot number and print it every reboot
@ -77,31 +95,52 @@ void setup() {
pinMode(GPIO_NUM_12, INPUT_PULLUP); pinMode(GPIO_NUM_12, INPUT_PULLUP);
} }
void loop() { void loop() {
Serial.println("------------"); Serial.println("------------");
Serial.flush(); Serial.flush();
delay(1000); delay(1000);
digitalWrite(GPIO_NUM_23, analogRead(GPIO_NUM_34) > 3500); digitalWrite(GPIO_NUM_23, analogRead(GPIO_NUM_34) > 3500);
Serial.println(analogRead(GPIO_NUM_34)); digitalWrite(OUTPUT_PUMP0, HIGH);
delay(1000);
Serial.println(analogRead(GPIO_NUM_35)); setAll2Off();
Serial.println(analogRead(GPIO_NUM_32)); digitalWrite(OUTPUT_PUMP1, HIGH);
delay(1000);
Serial.println(analogRead(GPIO_NUM_33)); setAll2Off();
Serial.println(analogRead(GPIO_NUM_25)); digitalWrite(OUTPUT_PUMP2, HIGH);
delay(1000);
Serial.println(analogRead(GPIO_NUM_26)); setAll2Off();
Serial.println(analogRead(GPIO_NUM_27)); digitalWrite(OUTPUT_PUMP3, HIGH);
Serial.println(analogRead(GPIO_NUM_14)); delay(1000);
Serial.println(analogRead(GPIO_NUM_12)); setAll2Off();
gpio_hold_en(GPIO_NUM_4); digitalWrite(OUTPUT_PUMP4, HIGH);
gpio_hold_en(GPIO_NUM_13); delay(1000);
gpio_hold_en(GPIO_NUM_15); 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(); gpio_deep_sleep_hold_en();
esp_deep_sleep_start(); esp_deep_sleep_start();