Hello all and thanks for looking.
I like so many others are working on a auto plant water system.
I'm using the 4 moisture sensors
4 valves that control the water output
and 1 pump to move the water to the plants.
What I'm stuck with is this:
Under "Sensor1" I check the sensor for moisture level. level under 10%
Then i convert that to a percent and display that percentage.
Now its time to water the plant.
I open the valve to the plant;
start the pump and dump 5 sec of water on the plant
THIS IS WHERE I GET STUCK.
I want to go back and make sure the plant has been watered completely. So I want to check the sensor again after 30 sec and make sure the plant is above 80%.
If not i want to apply more water to the plant and check the level again.
This is for my Bonsai plants. So the trick is to water the fully and them let them go down to very little water. I just dont want to keep added water all the time its not good for them.
Here is the code that includes all 4 moister sensors. If someone could point me in the correct direction to check the level again that would be great.
/this sketch is part of the auto water system. This code show sesensor connection and display.
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int sensorValue0=0;
int sensorValue1=0;
int sensorValue2=0;
int sensorValue3=0;
int SoilA0=0;
int SoilA1=0;
int SoilA2=0;
int SoilA3=0;
int RELAY1=LOW;
int RELAY2=LOW;
int RELAY3=LOW;
int RELAY4=LOW;
int RELAY8=LOW;
void setup() {
lcd.begin(16,2);
pinMode(RELAY1,OUTPUT); //Moisture Sensor 1,A0
pinMode(RELAY2,OUTPUT); //Moisture Sensor 2.A1
pinMode(RELAY3,OUTPUT); //Moisture Sensor 3.A2
pinMode(RELAY4,OUTPUT); //Moisture Sensor 4.A3
pinMode(RELAY8,OUTPUT); //Water pump
}
void loop() {
//moved to under the sensor configs
//int sensorValue0=analogRead(A0); //Int all sensors to Read inputs
//int sensorValue1=analogRead(A1);
//int sensorValue2=analogRead(A2);
//int sensorValue3=analogRead(A3);
//sensorValue0=constrain(sensorValue0, 485, 1023); //set the range of input value for all pins
//sensorValue1=constrain(sensorValue1, 485, 1023);
//sensorValue2=constrain(sensorValue2, 485, 1023);
//sensorValue3=constrain(sensorValue3, 485, 1023);
//Sensor 0
int sensorValue0=analogRead(A0); //Int sensor and read value
delay(20); //wait for sensor to settel
sensorValue0=constrain(sensorValue0, 485, 1023); //map sensor value to a number
delay(20);
SoilA0=map(sensorValue0, 485,1023,100, 0); //change value to 0-100 for percentage
// set up the LCD's number of columns and rows:
// Print a message to the LCD.
lcd.setCursor(0,0);
lcd.print("Soil Moisture_0");
lcd.setCursor(1,0 );
lcd.print(SoilA0);
lcd.print(" %");
if (SoilA0 < 10)
{
digitalWrite(RELAY1,HIGH);
delay(20);
digitalWrite(RELAY8,HIGH);
delay(5000);
digitalWrite(RELAY8,LOW);
delay(20);
digitalWrite(RELAY1,LOW);
}
delay(1000);
//Sensor 1
int sensorValue1=analogRead(A1); //Int sensor and read value
delay(20); //wait for sensor to settel
sensorValue1=constrain(sensorValue1, 485, 1023); //map sensor value to a number
delay(20);
SoilA1=map(sensorValue1, 485,1023,100, 0); //change value to 0-100 for percentage
// set up the LCD's number of columns and rows:
// Print a message to the LCD.
lcd.setCursor(0,0);
lcd.print("Soil Moisture_1");
lcd.setCursor(1,0 );
lcd.print(SoilA1);
lcd.print(" %");
if (SoilA1 < 10)
{
digitalWrite(RELAY2,HIGH);
delay(20);
digitalWrite(RELAY8,HIGH);
delay(5000);
digitalWrite(RELAY8,LOW);
delay(20);
digitalWrite(RELAY2,LOW);
}
delay(1000);
//Sensor 2
int sensorValue2=analogRead(A2); //Int sensor and read value
delay(20); //wait for sensor to settel
sensorValue2=constrain(sensorValue2, 485, 1023); //map sensor value to a number
delay(20);
SoilA2=map(sensorValue2, 485,1023,100, 0); //change value to 0-100 for percentage
// set up the LCD's number of columns and rows:
// Print a message to the LCD.
lcd.setCursor(0,0);
lcd.print("Soil Moisture_2");
lcd.setCursor(1,0 );
lcd.print(SoilA2);
lcd.print(" %");
if (SoilA2 < 10)
{
digitalWrite(RELAY3,HIGH);
delay(20);
digitalWrite(RELAY8,HIGH);
delay(5000);
digitalWrite(RELAY8,LOW);
delay(20);
digitalWrite(RELAY3,LOW);
}
delay(1000);
//Sensor 3
int sensorValue3=analogRead(A3); //Int sensor and read value
delay(20); //wait for sensor to settel
sensorValue3=constrain(sensorValue3, 485, 1023); //map sensor value to a number
delay(20);//map sensor value to a number
SoilA3=map(sensorValue3, 485,1023,100, 0); //change value to 0-100 for percentage
// set up the LCD's number of columns and rows:
// Print a message to the LCD.
lcd.setCursor(0,0);
lcd.print("Soil Moisture_3");
lcd.setCursor(1,0 );
lcd.print(SoilA3);
lcd.print(" %");
if (SoilA3 < 10)
{
digitalWrite(RELAY4,HIGH);
delay(20);
digitalWrite(RELAY8,HIGH);
delay(5000);
digitalWrite(RELAY8,LOW);
delay(20);
digitalWrite(RELAY4,LOW);
}
delay(1000);
}