From 04b52ca4ef7c46bd8678f722d1bb7736a0388791 Mon Sep 17 00:00:00 2001 From: "Kevin Veen-Birkenbach [aka. Frantz]" Date: Thu, 14 May 2020 16:40:51 +0200 Subject: [PATCH] Implemented possibility for multiple moisture sensors --- main/main.ino | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/main/main.ino b/main/main.ino index b98e7e8..9087861 100644 --- a/main/main.ino +++ b/main/main.ino @@ -28,7 +28,6 @@ const uint16_t PIN_IR_RECIEVER = D4; const uint16_t PIN_IR_SEND = D2; const uint16_t PIN_LDR = A0; const uint16_t PIN_ACTIVE_BUZZER = D5; -const uint16_t PIN_SOIL_MOISTURE = D3; const char* PARAMETER_PLUG_ADDRESS="plug_address"; const char* PARAMETER_PLUG_ID="plug_id"; @@ -196,9 +195,21 @@ String getJsonPir(void){ } String getJsonSoilMoisture(void){ - Serial.println("Reading soil moisture..."); - pinMode(PIN_SOIL_MOISTURE, INPUT); - return "{\"is_moist\":\""+String((digitalRead(PIN_SOIL_MOISTURE)==LOW)?"true":"false")+"\"}"; + Serial.println("Reading soil moisture from PIN ..."); + String moistures = "["; + int array_elements=(sizeof(PINS_SOIL_MOISTURE) / sizeof(uint16_t)); + for (int index=0; index