loading
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... http://borsaci06.com 
Here is the program, copy and paste it to Arduino IDE and upload:

/*  Dincer Hepguler 2013
*  http://borsaci06.com
*  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

#include
  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() {
  Serial.begin(9600);
  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(threshold);
  Serial.print(" ");
  Serial.print(val);
  Serial.print(" ");
  Serial.println(pos);
  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...
Hey I am making this project in my college can you please help me out more for details thankyou waiting for quick reply
<p>Hi, there. I am very interested in making DIY projects. I love yours but I have a little problem as I am a student of Class-12 I can't make just by reading small descriptions . I kindly request you to try to post a detailed plan. Can you help me out?</p><p>Hoping for an early reply!!</p>
<p>thank you for creating the sketch for a auto watering system! i have already ordered the parts from Ebay. i just finished copying the sketch and pasting it into my arduino IDE. i get back this &quot;error compiling&quot; message.</p><p>Arduino: 1.6.3 (Mac OS X), Board: &quot;Arduino Uno&quot;</p><p>auto_irrigation_sketch.ino:14:9: error: #include expects &quot;FILENAME&quot; or &lt;FILENAME&gt;</p><p>auto_irrigation_sketch.ino:15:3: error: 'Servo' does not name a type</p><p>auto_irrigation_sketch.ino: In function 'void setup()':</p><p>auto_irrigation_sketch.ino:24:3: error: 'myservo' was not declared in this scope</p><p>auto_irrigation_sketch.ino: In function 'void loop()':</p><p>auto_irrigation_sketch.ino:49:3: error: 'myservo' was not declared in this scope</p><p>Error compiling.</p><p> This report would have more information with</p><p> &quot;Show verbose output during compilation&quot;</p><p> enabled in File &gt; Preferences.</p><p>I have only been playing with my arduino for less than a week. i am not a programer, I am more of a builder. PLEASE let me know if you have an updated version that I can copy and paste. </p><p>PLEASE HELP!</p><p>THANK YOU!!!</p>
<p>The errors you are getting is mostly because of your Arduino IDE version... Things have changed a lot with V 1.6.0... If you are not using DUE then I advice you to use version 1.0.6 which is very stable... Indeed the first error you get is because you did not include servo library... try to add #include &lt;servo.h&gt; at the beginning of sketch... </p>
i have included servo and downloaded version 1.0.6, and now I'm getting this error message.<br><br><br>auto_irrigation_sketch.ino:16:9: error: #include expects &quot;FILENAME&quot; or
<p>Read my previous reply: </p><p>&quot;try to add #include &lt;servo.h&gt; at the beginning of sketch&quot;</p>
<p>hello sir!!!! v r doing automation of greenhouse using sensors... to automate irrigation v need an idea... since v ve built a small house v dont ve where to fit in d pipe... pls suggest some methods... my mail id abhivijaysugan@live.com</p>
<p>hi Din&ccedil;er!</p> <br><p>May I ask for your help in advising how to adapt the code and connections for a set of, say, 10 simultaneous sensors? Each manages its own pump.<br></p><div><div>I have plenty of flowers and would like to irrigate them all (on custom <br>separate humidity level each) by a single Arduino board.<br><br>The idea is to add also a photosensor to irrigate only when the Sun is down.<br></div> <br></div>
It should not be a problem as long as you have enough pins on your microprocessor... a small Arduino will not be capable but an Arduino mega has plenty of pins and will definitely do the job... I also have many plants on my terrace garden and irrigate some of them with a simple timer... some in my small greenhouse and are irrigated by another controller... the smart irrigateion in my instructable is for selected special care plants... So you must group your plants for smart irrigation....
<p>hye,sir</p><p>im electrical engneering student.</p><p>Im interested to do this project as my final project.</p><p>please send me information, complete project detail and programming details.</p><p>sankancu1724@gmail.com</p>
<p>sir, you are a brilliant minded man..! this is the coolest watering system ever created. I have seen you personal webpage and you have an old project under your facebook account. it is a plant machine made of an old record player, that keeps the plant alive. I have just seen it and my mind exploded. you should definitely put that on here !</p><p>.</p><p>but the reason why I'm reaching out to you is that I have a similar project that I am sure you will be very interested in personally. I see that you love plants so, check it out ! I am sure I will be messaging with you again soon enough, thank you for sharing your amazing skills !</p>
<p>Akin,</p><p>Thx for your kind words... I checked out your cool project too... Also sent you a comment on google+ too... cheers,</p>
<p>the link; <a href="https://www.instructables.com/id/The-Plant-Arm-Garduino-Upgrade/" rel="nofollow">The Plant Arm</a></p>
<p>I'm trying to establish this project, I wonder if I can replace the servo motor with a water pump, and how the program code will change? I need your help.</p><p>Thank you!</p>
<p>Asaad,</p><p>You can use a mini pump instead of servo. The advantage of the servo is to adjust the amount of water passing through the valve. however it is a bit noisy to keep the servo always on in both ways. Audible noise and EMI noise on the circuit... Indeed I used a pump in my implementation of this system on my plantoid robot, Mechaphytum Animus, which you can take a look at details on her page... There is an example code there too. While using a pump you must limit the amount of watering by keeping the pump on for some seconds... It is as easy as digitally keeping the pump pin high for a while...</p>
<p>Thank you for your help! I wonder if you can give me the link of the valve, because i'm finding difficlties finding the appropriate valve. </p>
<p>The valve is made by myself... It is a simple aquarium valve connected to servo arm with 2 small screws... But as I previously mentioned prefer to use a mini pump instead... Check out my implementation at my Mechaphytum Animus page... <a href="http://dh-sims-site.com/plantoid_project.htm" rel="nofollow">http://dh-sims-site.com/plantoid_project.htm</a></p>
<p>Interesting. I think I have that same sensor board and I found it gives a high when the humidity is high :-) which is too bad, coz if that was reverse, one could just use the sensor board to directly trigger a relay.<br><br>I understand that you are using its analog out, which is sensible, but it makes the sensor board itself superfluous because one could hook up the sensor directly to the analog input of the Arduino as a voltage divider.<br><br>I find your solution with the servo quite nifty</p>
<p>Yes you are right... sensor drops from high to low when soil humidity drops below your set level... but I didnot have any issues using this sensor that way... You are also right about the fact that the reverse would be nice to drive a relay without the help of a microprocessor... the working of this sensor on my Plantoid robot can be seen on my site... <a href="http://dh-sims-site.com/plantoid_project.htm" rel="nofollow">http://dh-sims-site.com/plantoid_project.htm </a> </p>
<p>interesting website :-) What do you hope to get from the stem sensor?</p>
<p>Stem electrode connection is the GND of capacitive and galvanic sensors... I have 2 sensors connected to the plant... Galvanic sensor gets readout from the leaf and capacitive sensor gets readout of human proximity...</p>
<p>definitely a plant ICU</p>

About This Instructable

29,310views

102favorites

License:

More by borsaci06:Touch Sensitive Robotic Skin Motorized TimeLapse Rig Motor speed control with brain... 
Add instructable to: