Lets make an automatic watering system. This project is an extension of our prior experiment, where you learned how to connect moisture sensor to Arduino. This time we are also going to connect a relay and water motor to the Arduino. We will then write a program to take input from soil moisture sensor and switch on or switch off the water motor based on the data received from soil moisture sensor.
What is Automatic Watering System for plants?
The automatic watering system helps you to water plants at your home, garden or farm in your absence. It uses technology to detect the moisture level of the soil and automatically water the plant when there is no moisture detected in the soil.
Can I make one myself?
Yes, this is what learn by watch do, helps you to learn to do things yourself. We have created a video and this post to show you the procedure to make it on your own. If you will follow both carefully you will be able to make it yourself. If you face any problem as in the comment. You can also ask us for the paid services.
How long does it take to make an automatic watering system myself?
It depends on your prior knowledge and experience with Arduino. If you are new to that and follow the video and instructions given in this post, you should be able to make it within a day. But if you are planning to showcase in some science exhibition, We recommend you to start at least one week prior to the deadline.
What are the required components?
The required components are given below. We have also provided links to buy the components from Amazon and Flipkart so you do not have to waste your time in search for the right component.
- Arduino Uno R3: http://amzn.to/2srIMT3 | https://goo.gl/MkGoQC
- Soil moisture sensor: http://amzn.to/2sQLiCJ | https://goo.gl/B9ewV6
- Buzzer: http://amzn.to/2sXK2sz
- 4 Channel Relay for Arduino: http://amzn.to/2s09f8s | https://goo.gl/Dtd7Xb
- Jumper wires: http://amzn.to/2s9wfkc | https://goo.gl/QK5BN4
Source code
int ACWATERPUMP = 13; //You can remove this line, it has no use in the program. int sensor = 8; //You can remove this line, it has no use in the program. int val; //This variable stores the value received from Soil moisture sensor. void setup() { pinMode(13,OUTPUT); //Set pin 13 as OUTPUT pin, to send signal to relay pinMode(8,INPUT); //Set pin 8 as input pin, to receive data from Soil moisture sensor. } void loop() { val = digitalRead(8); //Read data from soil moisture sensor if(val == LOW) { digitalWrite(13,LOW); //if soil moisture sensor provides LOW value send LOW value to relay } else { digitalWrite(13,HIGH); //if soil moisture sensor provides HIGH value send HIGH value to relay } delay(400); //Wait for few second and then continue the loop. }
KEVIN
24 Nov 2017plz help me!! When I am Uploading the program there is an error.the error states that “expected initializer before ‘WATER’. PLZZZ HELP ME
admin
1 Dec 2017Hi, there was a problem in first line. Replace AC WATER PUMP with ACWATERPUMP and the program should work. Infact you can remove first two lines of the program and it should work perfectly.
karthik
29 Nov 2017what language you are using for the code
admin
1 Dec 2017Arduino uses its own programming language. It comes with an IDE you have to learn how to write a program and how to upload it to arduino. Watch this tutorial: http://www.learnbywatch.com/how-to-connect-an-arduino-to-pc-or-laptop/
Vamsi Krishna
15 Dec 2017Hii sir actually we are doing a project similar to your’s. That we can water a plant at regular intervals of time including detection of moisture. briefly, if you have a habit of watering plants daily at 5 pm even in your absence the motor should on automatically and water the plants. The amount of water should be watered to the plants are based upon the moisture content in the soil. Please help us sir as early as possible.
Dr. Yogendra Pal
15 Dec 2017You need to write code for this logic:
If it’s 5 PM //read date / time from real time clock module ( http://amzn.to/2o8Hs69 )
{
if water need water // read data from soil moisture sensor
{
water the plant for 1 min // start the motor and stop it after 1 minute
}
}
I hope it will be helpful. Let me know if you face any problem.
Vamsi Krishna
19 Dec 2017Thank you so much sir…we are very happy for your help. If you don’t mine may we contact you through Gmail.
My mail id is
vamsikrishnan150808@gmail.com
Dr. Yogendra Pal
19 Dec 2017you can contact me here: yogendra.pal3@gmail.com
azmi abdullah
16 Feb 2018hi sir
i want to supply water without using water sensor and i want to supply water daily at 9pm for 5mins. can u please give me the program for that i am very poor in programming.you can mail me at azmiabdullah2013@gmail.com
Vamsi Krishna
19 Dec 2017You can send us your mail id to my mail so that we can Contact you if there any urgent need. I assure you that your mail id will be safe and not be misused.
Vamsi Krishna
19 Dec 2017Thankyou sir for your support
admin
20 Dec 2017Hi Vamsi, Please share your project story with us once you submit it. You can use images, videos, text etc and we will show it in our blog. You can submit your story at learnywatch@gmail.com
Erwin Mena
22 Nov 2018Sir what should i do if i want to use the combination of temperature and LDR sensor to water the plant ? . it is possible to make a code to arduino for this? . thanks for the answer sir.
admin
22 Nov 2018First, you need to learn how to connect temperature and LDR sensor to Arduino. After that, you need to utilize data received from these sensors to switch on/off water motor.
Yes, this is possible with Arduino.
Vamsi Krishna
15 Dec 2017Plz help us sir as we have less time to submit our project
Shashank
18 Dec 2017Can i use dc pump of 5 to 12 v with relay
Dr. Yogendra Pal
19 Dec 2017A relay is an electromagnetic switch operated by a relatively small electric current that can turn on or off a much larger electric current. So, you need relay only if you want to operate AC devices. You can directly send the signal (current) to DC motor, you do not need relay for that.
Let me know if this is helpful.
Shashank
19 Dec 2017Thank you for your support
Aida
2 May 2018Hello sir, i use aquarium pump instead of the motor. Is it okay of i didnt use the relay?
admin
3 May 2018A relay is an electromagnetic switch operated by a relatively small electric current that can turn on or off a much larger electric current.
So, if you want to give power to an AC device, use relay otherwise not.
Asish
21 Dec 2017sir actually we are doing an project similar to this but we want to know how to change the angle of the water pipe if we have 2 or more plants so that it can water the plant which has less moisture.
Asish
22 Dec 2017Sir please reply to my comment.
aditya
24 Dec 2017sir, i followed your steps and connected all components and wrote program too..but it works opposite to what you have showed when i place soil moisture sensor in wet soil the motor is on and when i remove nothing happens plz help ..
aditya
24 Dec 2017finally i solved my problem sir i just changed this values
{
digitalWrite(13,HIGH); //if soil moisture sensor provides LOW value send LOW value to relay
}
else
{
digitalWrite(13,LOW); //if soil moisture sensor provides HIGH value send HIGH value to relay
compare this with original program
this is working for me
when i remove the sensor from the wet soil the motor is on state and off when i place it in wet soil
anyway thx for program
sir,,
Tab
27 Feb 2018Hi. Can you help us? We are using this code but it didn’t work we are using a dc motor while the sensor is humidity sensor. Thankyou
aboude84
21 Jan 2018Hi can you add some code to control the power of the pump ?
A Phyu Yaung
22 Jan 2018If i want to make more than plant which components should add? A higher motor?plz reply i’m working for school project.
Sushant patil
7 Feb 2018Sir,can we add more than two plant for watring system using one motor..plz give me a code for that..plz help us
Neha Rajput
12 Feb 2018Instead of ac motor we use dc motor
Is it working in automatic watering system for plants.
When we don’t put soil sensor inside the soil water flow from pump but we put sensor inside the soil it will not work water is flowing continue instead of stoping
Plz help me what can i do.
Neha Rajput
12 Feb 2018Plz reply to my comment
aditya
15 Feb 2018where and how to connect buzzer?
Rv
25 Feb 2018Sir how to connect the rtc module on the circuit plsss explain it
kim
27 Feb 2018can i ask for a papers sir?thanks..
Salloo_Khan
7 Mar 2018sir may i get documentation of this project…?
Udag
9 Mar 2018In a same area it will dry in some part and wet in some part.In such condition s how can use make of this sensor
Graham Kendall
24 Mar 2018Great project. really enjoyed it. Could you do a project where you control this type of thing via wifi or app?
Yashwanth
26 Mar 2018Hi, I am receiving the reverse for the output…..when the soil moisture sensor is placed on dry soil then water is not flowing while water is flowing when the soil moisture sensor is placed in wet soil…How to overcome this?
Daniela Gayosso
6 Apr 2018Hi, please help me. When I compile the program at the beginning there is no error but when I want to upload it to the board it says that it can not as if it did not detect it.
Then, I got a 3-6 v motor and I connected it to a cell phone charger like in the tutorial but I checked all the connections and it does not work. I hope you can answer fast
Aziz
10 Apr 2018Hello
I am trying to write a code for two soil sensors using python. i got it work for one sensors , but i could not do it for two sensors, so my question is there a specific loop for two sensors ??BTW, I am using Raspberry pi
admin
10 Apr 2018Please share your code.
Aziz
11 Apr 2018GPIO.setup(16, GPIO.IN)
GPIO. setup(18, GPIO.OUT)
GPIO.setup(7, GPIO.IN)
GPIO.setup(7, GPIO.IN)
try:
while True:
if GPIO.input(16)==1
GPIO.ouput(18, True)
if GPIO.input(7)==1
GPIO.ouput(15, True)
else:
GPIO.setup(18, GPIO.OUT)
GPIO.output(18,GPIO.OUT)
GPIO.setup(15, GPIO.OUT)
GPIO.output(15,GPIO.OUT)
Aaron
16 Apr 2018I have coded the arduino and done all the connections as shown in the video but the pump isn’t coming on.can I get some help on making it work
Aaron
17 Apr 2018Can anyone tell me wat is the order in which v have to connect the wire in the relay
Ali Ahmad
17 Apr 2018help me how to connect pizzo buzzer in the arduino and code for buzzer
Nadim Hoque
24 May 2018Can i use 5v dc or 12 dc motor seam relay
Ishaan Goyal
6 Jun 2018Hi, I am a complete beginner. How to use this device for multiple plants at once? I mean if I use 2 motors and soil sensors, how to make it work for both?
PRATHAM
8 Jun 2018Hi
I am Pratham
The coding you gave in the videos not working can I ask for the correct coding I used 1 channel relay board instead of 4 channel relay board and other things are same
Thank you
admin
8 Jun 2018Please post the errors.
Kuljinder Singh
7 Jul 2018how to link this device with a gsm module
Ashok
16 Jul 2018The things working reversly ..like the water is being pumped when there is moisture and not being pumped when no moisture..please help me regarding this…
dan
18 Jul 2018send me the code of this project… pls..
Vineeth
3 Aug 2018Good stuff ! I’m willing to do this project but I have small query. What if water from source get empty ? Because if there is no water to suck, the motor can fail or damage. How to overcome this small issue?
Christy John Biju
24 Aug 2018Hi i am doing the project of automatic watering plants using arduino.
I have done the connections according to the video given.
I am sorry i did not understand the above codings posted in the above comments as i just have the very basic info. about coding done at school (c++).
The problem is that when i give the power supply to both the arduino and the dc water pump, the pump starts working and also the sensor is dry. But now is the problem….
The pump is running but according to the project the pump should stop when the sensor is dipped in water/wet soil. But that does not happen.
When i take it out it stops. Again when i dip it in water and take it out it starts. This happens only a few times and then stops and nothing works.
PLEASE SOMEONE SEND ME THE CORRECT CODING AS I HAVE TO SUBMIT THIS PROJECT NEXT WEEK AT SCHOOL.
The pins for the coding is given below…
The DO from the sensor – pin 9
Pin 12 from arduino – IN1 of relay.
Again please send me the correct coding and advice me if there is any problem.
Naveenkumar
24 Aug 2018Sir I want interfacing soil moisture sensor and DC motor program
sandesh Nayak
25 Aug 2018should we compulsorily use the channels for this project?
sandesh nayak
3 Nov 2018should we use only the 4 channels or we can use 2 channels also?
please answer me quickly because i have to complete the project
admin
3 Nov 2018You can use 1 channel relay as we are using only 1 channel out of 4 channels available in 4 channel relay.
RATHOD GOKUL
21 Nov 2018In automatic irrigation system we’re we use the buzzer
Bikash Kumar Gupta
25 Nov 2018Sir, I’m making this project and I want to know the power supply of adruino board. So, please help me to get the power adapter for this project. Please suggest me. I’m very thankful to you for your kind support.
kiran yaqoob
9 Dec 2018sir i followed all the steps given above.there is no error while compiling and uploded completely but project is not working :(.please help me
Vishwa
15 Dec 2018Sir how to know which variable should I put to describe the signal received from sensor
Vishwa
15 Dec 2018Sir my circuit is complete but the motor does not stop even when water is full in the pot .
I also don’t know which variable should I put to describe the signal received from the sensor. But still the programming is been uploaded.
fadzli
5 Jan 2019sir can i know all the circuit that use in this project
Ankur Patel
22 Jan 2019Sir I want circuit diagram
lhera
2 Feb 2019sir can we use aquarium pump rather than ac motor??..what should be the code are we going to use??
Ralph
11 Feb 2019Same question, my aquarium pump runs at 5 watts of power and 110-120/220-240 voltage
Ralph
11 Feb 2019Can i use an aquarium.pump with 5 watts of power and 110-120/220-240 voltage
surya
12 Feb 2019where i buy the draining motor?