Arduino Plant Watering System

Jeremy Bohrer
4 min readMar 24, 2020

When I am away from my plants for an extended period of time, I want to make sure they stay happy and well-hydrated, which is why I built an automated home watering system with an Arduino. I wanted the system to mimic how I water my own plants: wait until the soil is dry, then water the plant until the soil is moist. Making sure the soil is not waterlogged is crucial in getting enough oxygen to the root system. In this guide we will go step by step to create your own plant watering system with an Arduino.

When to Water Your Plant

The moisture sensor I used gives you a reading that is inversely related to how moist the soil is. If the sensor is in water, the measurement should be very low, while if the sensor is in air, the measurement should be very high. My goal is to create a sawtooth graph when measuring the inverse soil moisture over time representing watering the plant quickly, then waiting several days until the plant is dry again. To do this we also need to set two thresholds to determine when to start and stop watering.

sawtooth graph
  • WATER = 0
  • STOP_THRESHOLD = 1
  • START_THRESHOLD = 5
  • AIR = 6

When the inverse soil moisture exceeds the START_THRESHOLD, it should turn on a water pump and start watering the plant. I set it up so that it will water the plant a little bit every hour instead of a lot all at once. When the inverse soil moisture falls below the STOP_THRESHOLD, it should stop watering the plant and wait until the START_THRESHOLD has been reached to start watering again. One of the harder parts of this project was figuring out what the right thresholds are. They will change depending on how much water your plant needs so I suggest playing around with them in your code!

Parts

Schematic

Wiring It Up

  1. Connect the Vin pin to the red wire of the water pump. I connected both of the pump pins to the breadboard. I would also recommend soldering the pump wires to better wires for use with a breadboard.
  2. Add the MOSFET to the breadboard. Connect the black wire of the pump to the MOSFET drain. Connect pin 4 or any other digital pin to the MOSFET gate. Connect the MOSFET source to GND. Add a pull up resistor between the source and gate.
  3. Add the temperature sensor to the breadboard. The temperature sensor contains four pins and the third one is not used. Connect the first pin to Vcc (3.3–5V). Connect the second pin to pin 2 or any digital pin. Connect pin four to GND. Add a 10K pull up resistor between Vcc and the digital pin.
  4. Add the moisture sensor by connecting it to Vcc, GND, and A0 or any other analog pin.
  5. Place the motor in the water container and the electronics in a waterproof container. Thread the tube from the pump to the top of the plant soil.
  6. Upload your sketch and power with a 12V wall adapter.

The biggest gotcha I found when working with the Arduino and water pump is that the pump is meant to work at 12V, while when you attach the Arduino just to the USB cable, the Vin pin is much less than 12V, so make sure to test while supplying the Arduino with 12V! One worry I have with this setup is that the soil moisture sensor has exposed electronics and we are dealing with water. I reduced this problem by attaching my water tube to a drip feed to prevent overflooding the soil and frying the circuit. You could also look into buying a waterproof moisture sensor (pricey) or shrink wrap the exposed parts.

All relevant code can be found on github here. When you open up your serial monitor you should see an output like this:

09:00:48.048 -> Soil Moisture: Air, 522

09:00:48.081 -> Temperature: 77.00 *F

09:00:48.119 -> Humidity: 35.10 %

09:00:48.119 -> Starting to water

09:00:48.156 -> Water pump on

09:01:48.060 -> Water pump off

09:01:48.098 -> Done watering

Next

--

--