Introduction: Intelligent Watering System With Arduino...

In this instructable i wanted to share my automatic irrigation system using arduino, soil humidity sensor and a simple aquarium valve attached to a servo... Humidity sensor takes constant readings of the soil moisture and transfers to Arduino which controls a mini servo attached to a tiny valve. you can tell the system amount of moisture needed simply turning the potentiometer... then the system opens and closes the water valve if the soil is below your specified level of moisture... 
Parts needed:
- Soil humidity sensor   ( dealextreme $3)
- Arduino of any kind      (dealextreme $10)
- mini servo of any kind    ( 9gm ~$5)
- aquarium valve
- 10K potentiometer
- water pipe (thin aquarium type)

First dip the fork of the humidity sensor to soil completely... connect sensor to A0 and 10K pot to A1 pins of Arduino. connect servo to D9 pin. power up the system with anything you like... (Wall adapter or battery )... Upload the sketch to arduino, adjust the pot and there you go... you can adjust the level of watering needed anytime by the potentiometer... thats all... You can put the system in a small waterproof project box of any kind... you can make a battery operated handheld system and add a16x2 lcd display to show moisture and watering status... please dont hesitate to contact me for any help and don't forget to vote for me if you like it... :) My other projects are on my web site... 
Here is the program, copy and paste it to Arduino IDE and upload:

/*  Dincer Hepguler 2013
*  Read analog values from humidity sensor over the serial port
*  Command a servo controlled watering system

const int numReadings = 20;     //number of readings for smoothing

int readings[numReadings];      // the readings from the analog input
int index = 0;                  // the index of the current reading
int total = 0;                  // the running total
//int val = 0;                // the average

  Servo myservo;        //create servo object to control a servo
  int sensorPin = A0;    //humidity sensor at A0 (analog0)
  int pos = 90;         //variable to store servo position and set servo to center
  int thresholdPin = A1;  //threshold pot at A1
  int val = analogRead(sensorPin);
  int threshold = analogRead(thresholdPin);
void setup() {
  myservo.attach(9);  // attaches the servo on pin 9
  // initialize all the readings to 0:
  for (int thisReading = 0; thisReading < numReadings; thisReading++)
    readings[thisReading] = 0;

void loop() {
  // subtract the last reading:
  total= total - readings[index];        
  // read from the sensor: 
  readings[index] = analogRead(sensorPin);
  // add the reading to the total:
  total= total + readings[index];      
  // advance to the next position in the array: 
  index = index + 1;                   

  // if we're at the end of the array...
  if (index >= numReadings)             
    // ...wrap around to the beginning:
    index = 0; 
  int threshold = analogRead(thresholdPin);
  val = total / numReadings;             // calculate the average 
  if ( val > threshold)   { pos = 180; }   //open valve if dry
  else { pos = 60 ;}                         //keep valve closed otherwise
  myservo.write(pos);                 // sets the servo position according to the scaled value
  delay(15);           // waits for the servo to get there
  Serial.print(" ");
  Serial.print(" ");
  delay(10);       // delay in between reads for stability

NOTE: I couldn't manage to add include statement, it dissappears during copy and paste... so don't forget to add an #include servo library...
Weekend Projects Contest

Participated in the
Weekend Projects Contest

Arduino Contest

Participated in the
Arduino Contest