Introduction: Automatic Plant Watering and Soil Moisture Sensing

Picture of Automatic Plant Watering and Soil Moisture Sensing

There are many such instructable created. But the problem is with getting the materials. I am creating this so that people get to know what equipment to buy in India and how to connect them and make them work.

Problem Statement -

1. Can we automatically water the plants when i am going on vacation or do i have to bother my neighbors? Sometimes the neighbors do too much of watering and the plants end up dying anyway. There are timer based devices available in India which water the soil on set interval. They do not sense the soil moisture and the ambient temperature to know if the soil actually needs watering or not.

2. Can we know if the soil actually needs to be watered? Irregular watering leads to mineral loss in the soil and might end up rotting the plants.

3. Can we manually water the soil from remote location?

Solution -

The answer is "Yes, we can" to all the above problem. The solution provided is simple and economical. It requires you to know little bit of electrical and electronics but i feel it is similar to having so much of electrical knowledge so that you can change a bulb. Let me know if you feel any step is complicated. I will try to add more information so that it becomes easy.

Step 1: Materials Needed

1. Soil moisture sensor - (You can search for similar item on ebay)

2. Small pump - Toy pump working on 5-6V is enough. Few options available in India are - this should not be submerged in water) should be submerged in water)

3. Arduino -

4. Pump Controller - (You can make your own circuit with little knowledge of soldering or you can go to shops who sell these electronic equipment and they can point you to people who can help you to solder)

a) Transistor - 2N2222A

b) Resistor - 1K ohm

5. Drip Irrigation Kit - (You can choose depending on how many plants you want to water).

6. Connecting Pipe (i used 0.4" pipe) to connect the pump and the drip irrigation main line.

Step 2: Connect the Soil Sensor to the Arduino

Picture of Connect the Soil Sensor to the Arduino

I have color coded the wires for easy understanding of how to connect the soil sensor with the arduino.

a. Red wire - Connect the Vcc pin on soil sensor to the +5V pin on arduino

b. Green wire - Connect the Gnd pin on soil sensor to the Gnd pin on arduino

c. Orange wire - Connect the A0 (Analog) pin on soil sensor to the A0 (Analog) pin on arduino

Step 3: Connect the Pump Controller Board to the Arduino

Picture of Connect the Pump Controller Board to the Arduino

The Pump Controller Board comprises of -

1. 1k ohm resistor

2. 2N2222A transistor

3. 5V Pump Motor

Step 4: The Code to Be Uploaded to Arduino

Copy the code from Code.txt to the .ino file on arduino and upload the code to the arduino.

Step 5: Setup the Drip Irrigation Kit

Picture of Setup the Drip Irrigation Kit

There is enough information on the web on how to setup the drip irrigation kit. I am not getting into details of this.

The point to note here is that there are 6 analog pins on arduino that can be used to sense soil moisture. At the very minimum, one can use the same setup to sense 6 plants. But if designed in a better way, one can use the same setup to sense as many plants in multiple of 6.

I am not going into details of this as this is not the objective of this instructable. I will try to publish another instructable for a better design of the drip irrigation kit so that maximum number of the plant soil moisture can be sensed.

Step 6: Connect the Pump to the Drip Main Line

Picture of Connect the Pump to the Drip Main Line

Step 7: Demonstration of the Full Setup

Step 8: Next Steps

  1. Create an Internet of Plants - Create a IOT framework which will help connect plants of similar variety across the world to get connected.
  2. Connect the arduino wirelessly with the raspberry pi home server so that the plants can be monitored remotely.
  3. Remote Monitoring and Watering of plants - Use GSM based add on board for remote operation
  4. Power Supply - Use solar power as the power need is low. Currently i am using a power bank to power the arduino and the pump motor.
  5. Weatherproof case - Since the device will be used outside, we need to have a weatherproof case to house the electronics.
  6. Add more sensors - Temperature sensor, Humidity sensor.

Do let me know if you think anything else needs to be done as part of this project.


shopoholicanusha (author)2017-11-11

The idea is to add the solenoid valve where you have connected the pump to the Arduino in your circuit diagram. Instead of the pump being triggered by the moisture sensors, the input from the sensor would control the solenoid valve. The valve will be connected to the tap. You can leave the tap on since the valve would regulate the flow of water from the pipe
I still need to implement it. Not very good with electronics. Am just learning :)

shopoholicanusha (author)2017-10-28

Instead of using a pump to pump the water, I want to connect the irrigation system directly to the pipe in my kitchen. Is there a stopper that can be used to stop the water flow from the pipe once the soil moisture is in the optimum level? These kind of stoppers are being used in a lot of washing machines. I wanted to know what is the terminology for these stoppers

You can use a solenoid valve. I would like to know how your project goes since i have never used this device.

JamieT83 (author)2017-06-22

We are modifying this system to include an Individual pump for each plant with sensors, this way each plant can be sent the water it needs.

I'm also adding a Solar panel to charge a Battery that will operate the pumps.

My current system will include 5 pumps, 2 sensors for each plant, Solar Panel and a Rechargeable battery.

JamieT83 (author)JamieT832017-06-22

And we added a Distance Measuring Transducer Sensor to monitor the Water level from our source, this way the pumps don't run if we don't have water.

cmartin35 (author)JamieT832017-06-26

This is amazing. Will you be updating the instructable with these changes?

marzouk100 (author)2017-06-17

My friends have changed MOISTURE LEVEL from 255 to 550 work with me Try this suggestion and tell me the result

RutulG (author)2017-05-14

Hi! Can You please explain how the Motor will be used to Pull the Water. The Photo of Motor with Irrigation kit will be more helpful. How the Motor output to connect to pipe for pulling the water.

Nitishh37 (author)2017-04-27

How to create the Internet of Plants??

YounisD (author)2017-01-22

Hii sir i want to do this project so what i have to do can u help me sir.

ShaunP37 (author)YounisD2017-04-03

Isn't the point of instructables to provide instructions on how to do the project? What part are you stuck on? Do you already have all the hardware?

Jean Pierre 2 (author)2016-12-27

This is one of the most interesting project. It is very similar to an arduino project "Un Arrosage Automatique". in a french translation , Dunod, Paris, 2011,2013, 2015, "Démarrez avec Arduino" by M Banzi and M Shiloh pp 77-142. I will try to combine the best of the 2 projects and let you know.

We want to make a system able to optimise the individual plant potential in a permaculture environment. Any comment is welcome here or at

Jean Pierre

Nivethar4 (author)2016-12-21

hii sir i´ḿ doing project in automation of drip irrigation using soil moisture, 12 V relay, 12V solenoid valve, and an LCD. Can u send me the program required to get the output @

Sushmita Sapkota (author)2016-12-13

will you please send me the complete code at :

ahmedsha (author)2016-12-01

it would be nice if u could immediately response


ahmedsha (author)2016-12-01

sir i am using a 12 v water pump. so how can i program the arduino or modify your program

satyarthaprakash (author)2016-10-17

@AmitabhS Sir can you share the complete code using Arduino Uno board......

Hi sir did u get the code?

Multi tasker2 (author)2016-11-14

Is the code complete? Sir could you mail me the full code . I am a new one to electronics ..... if anyone else has received the code from the author please mail me as soon as possible .

mail me at ... -

Hi sir did u get the code?

AmitabhS (author)2016-11-14

I have already shared every information (including the code) that i have.

royceibay19 (author)AmitabhS2016-11-28

Hello sir could you mail me the full code. I am your number 1 fan. Thanks you . please sir we really need your help.

ginSlaw06 made it! (author)2016-10-18

hello good morning....

can u help us out?

for the sake of our project?

we are using an arduino, 2n5551 transistor,1kohms resistor,12 volts water pump, breadboard and we need to supply 12 volts battery, we also use soil moisture sensor.......

we had search on the net program...but it seems it dont fit the program coz we are using 12 volts battery while on the link we searched they are using 5 volts water pump......

this our connection..can u help us the coding...pls....

our system is automatic plant watering system wherein....the moisture sensor itself will detect if the soil of the plant is wet or dry,,,,,if the sensor detect the soil of the plant is dry ....the water pump will water the plants and if the sensor detects the soil is wet,,,,,,the water pump will stop and will not water the plants....

can u help us out a complete program....


this my link addresses:

IssabelB (author)2016-10-05

Do you have the specifications for the fly back diode needed? Thank you!

Thanooja (author)2016-07-18

project is nice. i wanna do this as my project can you send me block diagram and details about the project in detail to my mail


plzzz sir.send me

rabbithomes made it! (author)2016-07-17

dear all ,

The “ smart garden”uses the most advanced Internet, cloud and mobile technologies to intelligently manage garden's irrigation and lighting scheduling. In a typical garden, the system can save up to 50% of the irrigation water."
please visit our website for more information , Smart garden PRO ..

AyushB22 (author)2016-06-13

Sir, I am doing a project on automatic soil moisture sensing and irrigating for a single pot. Can you please send me complete circuit and block diagram and also specifications of pump ,relay and FPGA (xillinx) programming code. Can we use submersible pump for this project?.

please mail to this as early as possible...

BramS3 (author)2016-06-10

Nice project, have you ever though of putting the system "in line" so that you do not need a resevoir, it comes straight from the hose?

InarcoC (author)2016-05-26

Ok, to control six individual plants, I should use six pumps connected to six different out ports, am i right?
Also, what platform do you think is better for this, arduino, raspberry...?

TarashT (author)2016-04-25

when i connect the negative terminal of battery to the ground my transistor starts heating intensly..... where is the mistake plz help

diy_bloke (author)TarashT2016-05-20

What mpotor are you using? could it be that it just draws too much current for the transistor?

Test13 (author)2016-04-16

Hey guys, just one clarification - You connect the positive terminal of the battery to the motor and the negative terminal of the battery to the ground port. I am new to arduinos so could someone just confirm this. Thanks

diy_bloke (author)Test132016-05-20

Well, yes, but the Arduino still needs 5 Volt as well

vidyas18 (author)2016-04-26

please someone help watever i do motor not turning on ???? how to control moisture sensor ?

diy_bloke (author)vidyas182016-05-20

thats kind of a broad question, could be your connections, could be the software, could be the motor.
Lets do some fault finding:
if you remove the sensor board and alternatively connect A0 with +Vcc or Ground, does the motor turn on?
If you just write a HIGH to D7, does the motor turn on?
btw, add a fly back diode over teh motor or it may burn out yr transistor, maybe it already did

diy_bloke (author)2016-05-20

I would definitely add a fly back diode over the motor to prevent your transistor from being destroyed

poojag14 (author)2016-04-16

Sir, I am doing a project on automatic soil moisture sensing and irrigating for a single pot. Can you please send me complete circuit and block diagram and also specifications of pump ,relay and Arduino programming code. Can we use submersible pump for this project?.

please mail to this as early as possible......

nikobugs (author)2016-03-28

Hi. Can anyone send me the coding for this? Thank you very much

I'm using timer and the moist sensor for this project.

siddheshg1 (author)2016-03-11

We facing problem during proteus simulation and programming.
Please help us.
We use same moisture sensor that u use.
Please send me email my email id is
Please rply in 1,2days
Thank u sir

siddheshg1 (author)2016-03-11

We facing problem during proteus simulation and programming.
Please help us.
We use same moisture sensor that u use.
Please send me email my email id is
Please rply in 1,2days
Thank u sir

siddheshg1 (author)2016-03-11

Sir please provide c code and hex file of same project but gsm based with atmega32

jaykid (author)2016-02-15

Hi everbody, after playing around with the code a little I made some progress towards haveing the sensor OFF every X amount of time :). at first I tried using delay function although it worked, it also kept the pump ON for the same amount of time as OFF (even after the moisture /water level was full) So basically I swapped the order in which things happen, so it will read the input from the sensor, then if water/moisture is high, it will power down the sensor for X amount of time, otherwise it will turn the pump on and keep it powered until the moisture level is high again. I also made a slight change and hooked up the positive pin of the sensor to PIN13 OUT instead of the +5V PIN. this way I have control of the sensor to turn it off and on. Please forgive me for my ignorance /bad codeing, but so far it seems to work :). Just play around with the values to understand how it works so you can suite it to how you want it. Hopefully someone who knows what they are doing can make this even better! thanks and T.C!

const int VAL_PROBE = 0; //Analog pin 0
const int MOISTURE_LEVEL = 450; // the value after the LED goes on

void setup()
pinMode(13, OUTPUT);
pinMode(7, OUTPUT);


void loop()
int moisture = analogRead(VAL_PROBE);

Serial.print("Moisture = ");

if(moisture < MOISTURE_LEVEL)

terian (author)jaykid2016-02-25

Look at this for more power saving better than delay

appLeS1 (author)2015-12-28

Sir is it possible to have multiple pots of plants and each pot have independent sensors which will trigger according to the different water needs of each pot.example i have pot A B C D and if B needs water it is only the B water tube that will have water in it.Are we required to use one pump per pot or one or two pumps will do.coz its very costly.thanks..

hoping for your reply sir.thank you

terian (author)appLeS12016-02-23

It is possible of course but you would need to use more than one pump (pump for each sensor) or use electrically controlled valves to open and close the water tube to each pot independently

BramS3 (author)appLeS12016-02-03

I am not an expert so please do not take my word for it, but I believe that you should be able to have one pump supply all of the water, and have a splitter at the end. You will need individual water controllers for each "pot". As long as all the pots are not all being water at once, as the one pump would not be able to supply enough water, I think you would be fine.

terian (author)2016-02-23

Hi, There is another good modification that you should add. Imagine the case where the reservoir goes empty, your system would still run the pump and it would run indefinitely and eventually burn out (no water in the reservoir and the soil is dry so it will stay dry). A water sensor in the reservoir would be the idea and checking through the code.

AmitabhS (author)2016-02-15

Good to see jaykid that you came up with a solution of your own. I am happy to see people are taking the concept forward and trying to implement it in their own way. You should find out what is the current capacity of the sensor since the arduino pins are rated at 40mA only. Ideally the power circuit should be separated from the logic

jaykid (author)2016-02-13

Thank you very much for this tutorial! this is my first project I have built it and works great :) by far the easiest build from all the others!

I only had to adjust the MOISTURE_LEVEL part of code so it works to my needs. However I am a complete amateur in coding and have been trying with no success so far, but I am wondering if anybody could help with "how to power the probe down" because it could save alot of power if we only take a reading every few hours instead and would also stop the probes from creating electrolysis. Thank you everybody! I will keep trying!

SANKETA3 (author)2016-02-07

Hello sir , we are working on the same project. This article is a huge boost to our project. We would be very grateful if you could mail me @ all the details as in code and all the minor details as well. Thank you.

About This Instructable




More by AmitabhS:Automatic Plant Watering and Soil Moisture SensingArduino Projects
Add instructable to: