Watering System for Indoor Plants, Feedback Controlled by Arduino

Introduction: Watering System for Indoor Plants, Feedback Controlled by Arduino


So, holidays was approaching real fast and we need a solution to keep those precious plants moist and happy. So i thought why not learn a little about arduino and electronics and build a watering system. As i have no previous knowledge about electronic components, I found some inspiration online that got me going. So ofacuse here a month or two later i would like to share my findings and give back to the community that way. I thought i would just have to learn some electronics stuff and maybe a bit of code, but like any good adventure, i ran into problems i didn't anticipate at all, described in the Unexpected Problems section. It all worked out in the end though and i hope you will find it useful. Enjoy!


Note on the images that the water source is below the plants. If you put the water source above the plants, you might end up in a situation where water will suck more water out of the bucket until it's empty, even though you have turned the pump off. So, just keep the water source under the delivery targets. Also note that the pump is placed on ground level. For the pump to be any good, it needs to be filled with water and this is achieved by keeping the pump at or below the lowest possible level that the water source might be. In short; a pump without water in it won't pump anything.

Getting the water to the plants

On the image you see a hose drawn from the bucket water source, which is placed lower than the plants on purpose, through each plant. At each plant one or more tiny holes are made on the hose and some sort of "splash control unit" is applied so the water doesn't spray out of the holes everywhere. I 3D printed my own, but you can use some plastic or whatever. In the end, the hose is closed, by bending it a few times. This is important as you don't want the loose end to spray water everywhere. So what's happening? It turns out the pressure inside the hose is pretty important if you want a consistent water outlet. This is achieved by closing off the end of the hose. Now, first time you set this up, the plants closest the pump will get more water, because of the hose being empty. But once the first or second pump cycle is complete you will notice water still resting inside the hose; it doesn't get pulled back down to the bucket water source. This is because of the holes nearest the pump will suck in air as the water from that point retreats, and that is a good thing. On next water cycle that remaining water will help build water pressure in the hose fast and ensure all plants get water. If a plant needs more water than the others, just add another small 1 mm hole to the hose. I used a drill and the smallest drill bit i could find.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: The Electronics

I know you don’t have time for long explanations, so here is the diagram.

When the button on the breadboard is pushed, 5v is applied to the mosfet and the pump will start. If you don't have a button you can skip that and left most diode.

Shopping list

1 Arduino Uno, https://www.ebay.co.uk/itm/UNO-R3-Arduino-Rev3-AT...
1 moisture sensor. https://www.ebay.co.uk/itm/Soil-Sensor-Moisture-H...
1 12w power supply, that can deliver minimum 2 amps, if you are going with the pump i'm suggesting. I used the over dimensioned 10 amp one (12V 120W 10A): https://www.ebay.co.uk/itm/DC-12V-LED-Driver-Powe...
1 water pump 12v. This is cheap from a car: https://www.ebay.co.uk/itm/DC-12V-LED-Driver-Powe...
1 MOSFET 520 type n + some sort of heatsink. I used a big coin i had laying around. Not as effective as a real heatsink but it gives me just enough pumptime without burning down the mosfet.
2 diodes. I just used one that came with the arduino set. It seems to do the job.
1 usb power supply for the Arduino.
1 breadboard and wires. Try to reduce wirelength and use solid wires where possible.
5 or 10m of hose with internal diameter of 5 or 6mm.

Step 2: The Code

Download the PlantWatere.ino file (found in the end of this step) and have a look at it in a text editor.

This code will take measurements periodically and if the soil moisture drops below a certain point, it will run the pump for a set amount of time.

The water pump shouldn't be run without liquid in it, so I've build in a safeguard into the software in case the water runs out; if the moisture measurement have not increased after two consecutive pumps, we go into failsafe mode and stop all actions. The failsafe mode is indicated by blinking S.O.S on the on-board LED. To exit failsafe mode just click the onboard reset button.

If you want to know more i highly recommend reading through the code. Code is executed one line at the time. The loop() part loops endlessly. i've added comments to help you understand what's going on, on each line. If you are totally new to programming, you probably could find a good tutorial online.. but here's a few hints: A function call like FailsafeCheck() will jump program execution down to where the function is defined, and continue code execution there. once there are no more code to execute in the function, execution will return to where the function was called and continue from there. Pay attention to the first lines of code. These are variables that you probably need to adjust to fit your situation, ie run the pump for longer or lower/raise the watering threshold. I recommend that you first set off to gather some information about your plant's environment. Namely what moisture values your sensor is giving you, while you water your plant and through the day. I left my laptop on and used a freeware program called CoolTerm to log all data sent from the arduino. By doing this for some days a pattern emerged on the graphs and by looking at the plant a few times a day, i could figure out at what value i should start watering to keep the plants somewhat happy (see graph at top of this step). Every time the code takes a moisture measurement it will print it to the terminal (if one is connected), in the format [milliseconds since last arduino startup]-[moisture level in percent].
I have tried a few different moisture sensors and some of them are more sensitive than others, meaning they might see somewhat dry soil as wet or wet soil as a bit dry. Luckily i found a sensor that seems to work fine with my program settings. The raw sensor data is typically a value between 0 and 1024. The program uses a math function to map that value to a corresponding value between 0 and 100, while preserving the scale of the value (eg 50 on the first scale is low on the scale so the mapped value would be low on the 0-100 scale as well). If your sensor is different than mine you might want to try and map the values to a scale with different min and max, or skip mapping all together and just go on the raw sensor output.

Step 3: Unexpected Problems

Notice the moisture sensor draws power from a “digital out” pin. This is to get around an interesting problem where this type of moisture sensor actually dissolves in the soil if power is left on. So instead of leaving power on we only turn power on just before we take a measurement and this will extend the lifetime of the sensor from a week or two to proberbly years.

MOSFETs get hot... Real hot.. Real fast. And will smoke if not cooled, when the pass-through current has over 1 amp. Really, add a heatsink BEFORE you power it up for the first time.

Before arriving at the water distribution solution described in "Getting the water to the plants", i tried a couple of things. First off i tried to lay a hose near all the plants, then split the water hose whenever i got near a plant with a Y-splitter. Then on the short peace of hose going to the plant i would put a clamp to try and control the amount of water coming out there. This design failed however because the clamps couldn't really control the water well and the amount of hose got way to big, so i would have to run the pump for longer witch is also a problem because of the heat generated in the mosfet.

Next i tried to pump 15 seconds worth of water up on top of a pet bottle that would acts as a reservoir. In the bottom of the pet bottle i would connect a hose and then add Y-splitters so i end up with 4 hoses going to each plant. I would try to regulate the water with clamps. My thought was that the water would distribute it self down through the hoses evenly, but what would actually happen was that one or two hoses would lead all the water down fast and the other hoses would suck in air, leaving 2 of 4 plants dry and the others drowning. I then abandoned the clamps as controlling units all together.

Thanks to

This guide for inspiration: https://www.instructables.com/id/Arduino-Plant-Wate...
www.uppsalaMakerspace.se for moral support & ping-ponging.
Helena Jones for providing test subjects and morale support.

Water Contest

Participated in the
Water Contest

Be the First to Share


    • Trash to Treasure Contest

      Trash to Treasure Contest
    • Wearables Contest

      Wearables Contest
    • Fix It Contest

      Fix It Contest

    3 Discussions


    10 months ago

    Here 10 months after the install, its still working flawlessly. The basilica from last summer loved the demand driven watering system and produced countless dishes of pastasause and lots of pesto. I also got some seeds so currently 2. generation of the plant is growing. Soon i will replant and move the sensor to a new bigger pot. That might require some adjustments for the other plants on the tube.

    Some minor adjustments i am considering:
    Changing to a 5 volt in-water water pump, if one exists, to reduce noise. Adding a solar panel and a 18650 battery cell to disconnect from the grid. Adding light measuring so the pump wont turn on in the middle of the night.


    Tip 1 year ago

    Very very good

    Very cool. I wish that I had something like this to water my plants when I am out of town.