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 will I learn from this video and post?

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.


  1. How to Connect an Arduino to PC or Laptop
  2. Soil Moisture Sensor with Arduino

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.

  1. Arduino Uno R3: http://amzn.to/2srIMT3 | https://goo.gl/MkGoQC
  2. Soil moisture sensor: http://amzn.to/2sQLiCJ | https://goo.gl/B9ewV6
  3. Buzzer: http://amzn.to/2sXK2sz
  4. 4 Channel Relay for Arduino: http://amzn.to/2s09f8s | https://goo.gl/Dtd7Xb
  5. 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
  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.

Frequently Asked Questions

Why to use arduino?
Arduino was programmed or we have to programme it?
Error! it expected an initializer before WATER
Which version of Arduino will work?
Which pump can I use, 12v or 5v?
Can I make it for more than 1 plant?
Why did you killed the plant?


  1. plz help me!! When I am Uploading the program there is an error.the error states that “expected initializer before ‘WATER’. PLZZZ HELP ME

    • Hi, 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.

Leave a Reply