Soil sensor and watherpump on a relay

I am a very neewbe but i have a small project to automatic wather the plants home.
i am not sure what is going on but i need some help to finish it
I am very sorry for my poor english but i hope some one can help me.

#int Soil1 = A0; //Soil hum sensor
#int Soil2 = A1; //Soil hum sensor
#int Soil3 = A2; //Soil hum sensor
#int Soil4 = A3; //Soil hum sensor
#int pump = 3; //WatherPump on a relay

void setup() {

Serial.begin (9600);

pinMode(Soil1, INPUT);
pinMode(Soil2, INPUT);
pinMode(Soil3, INPUT);
pinMode(Soil4, INPUT);
pinMode(pump, OUTPUT);

}

void loop() {
sValue1 = analogRead(Soil1);
sValue2 = analogRead(Soil2);
sValue3 = analogRead(Soil3);
sValue4 = analogRead(Soil4);

if (sValue1 + sValue2 + sValue3 + sValue4 / 4 <= 400) {
digitalWrite(pump, HIGH)
Serial.print("The plant need some wather, it will now be started")
Wait 5
digitalWrite(pump, low)
delay 21600
}

Else
digitalWrite(pump, low)
Serial.print("The Plant dont need wather right now")

}

Welcome in Arduino world,

  1. Please add code tags when you post code - it is the # button above the smileys (you can even modify your post)
  2. The code as posted won't even compile

Try this

  • made C++ syntax right
  • encapsulated 2 functions
  • added header for documentation
  • adjusted variable names
  • removed the delay of 6 hours as that is quite long
  • added a one second run at the begin to test the water pump
  • added timestamp to output
  • analog ports do not need to be set as INPUT by default
//  AUTHOR: rob tillaart
// VERSION: 0.1
// PURPOSE: waterpump
//    DATE: 2014-03-30
//     URL:
//
// Released to the public domain
//

const int Soil1 = A0; 
const int Soil2 = A1;   
const int Soil3 = A2;     
const int Soil4 = A3;  
const int waterPump = 3;

const int DRY = 400;

void setup() 
{
  Serial.begin (9600);
  Serial.println("Waterpump 0.1");

  pinMode(waterPump, OUTPUT);
  digitalWrite(waterPump, LOW);   // ensures off state
  Serial.println("Test waterpump at start");
  giveWater(1);
}

void loop() 
{
  int hum1 = analogRead(Soil1);
  int hum2 = analogRead(Soil2);
  int hum3 = analogRead(Soil3);
  int hum4 = analogRead(Soil4);

  int averageHumidity = (hum1 + hum2 + hum3 + hum4) / 4;

  if ( isDry(averageHumidity) ) 
  {
    Serial.print(millis / 1000); // timestamp
    Serial.println("\tThe plant need some water, it will now be started");
    giveWater(5);
  }
}

void giveWater(int seconds)
{
  digitalWrite(waterPump, HIGH);
  delay(seconds * 1000L);
  digitalWrite(waterPump, LOW);
}

bool isDry(int humidity)
{
  return humidity < 400;
}

Thank you for the code, i have done some testing with it.

i have removed on of the sensors so it will have 3 not 4.

But there is an error in the code that i don't quite understand.

//  AUTHOR: Rob Tillaart 
// VERSION: 0.1
// PURPOSE: waterpump
//    DATE: 2014-03-30
//     URL:
//
// Released to the public domain
//

const int Soil1 = A0; 
const int Soil2 = A1;   
const int Soil3 = A2;      
const int waterPump = 3;

const int DRY = 400;

void setup() 
{
  Serial.begin (9600);
  Serial.println("Waterpump 0.1");

  pinMode(waterPump, OUTPUT);
  digitalWrite(waterPump, LOW);   // state off
  Serial.println("Test waterpump at start");
  giveWater(1);
}

void loop() 
{
  int hum1 = analogRead(Soil1);
  int hum2 = analogRead(Soil2);
  int hum3 = analogRead(Soil3);

  int averageHumidity = (hum1 + hum2 + hum3) / 3;

  if ( isDry(averageHumidity) ) 
  {
    Serial.print(millis / 1000); // timestamp
    Serial.println("\tThe plant need some water, it will now be started");
    giveWater(5);
  }
}

void giveWater(int seconds)
{
  digitalWrite(waterPump, HIGH);
  delay(seconds * 1000L);
  digitalWrite(waterPump, LOW);
}

It is the part : if ( isDry(averageHumidity) )

Error:

sketch_may01a.ino: In function 'void loop()':
sketch_may01a:36: error: 'isDry' was not declared in this scope
sketch_may01a:38: error: invalid operands of types 'long unsigned int ()()' and 'int' to binary 'operator/'

Hope you cant help

The function should be declared before use, so move ti up in the source.

as the const DRY is defined the function should read as ...

bool isDry(int humidity)
{
  return humidity < DRY;
}