Intro: Arduino Plant Watering System - With Simplest Possible Moisture Sensors
In this Instructable, I'm attempting to condense the contents of two videos I made about my watering system, to take the best aspects from the builds in each video.
You will need:
- Arduino (I used a Pro Nano, but an Uno will do fine)
- * DC pump (search for 3-6V or 5V mini submersible pump)
- Plastic or silicone hose with an *inner* diameter of 6-7mm, or another size if your pump has a differently sized water outlet
- 2 x 6-wide row of header pins - 0.1 inch / 2.54mm spacing, the bent variety if possible
- 3-4 metres of 2 core mains electrical cable or any other durable flexible wiring - I just find mains cable convenient
- 6V AC/DC converter / power supply / wall wart
- 7805 5V 1A Voltage Regulator
- IRF44N n-channel MOSFET
- 4 x 10k resistors
- 2 x 1M resistor
- 2 X LEDs (optional, as an indicator to show the sensor has been triggered)
- Various jumper wires
- Breadboard with adhesive base
- Electricians tape and / or heatshrink
- Box large enough to hold the breadboard
- If using a metal box - Gromits, about 6mm internal diameter - big enough to fit the wires through
- Plastic tray, big enough for your plantpots to sit inside
- Cooling rack (for cooling baked goods, etc) - small enough to sit on the bottom of that tray
- Another plastic tray or 5 litre water bottle, to act as a water reservoir
- A plastic nozzle, for example from a garden hose connector or washing machine tap adaptor
- Hot glue gun
- Duct tape
- Small clamps or clothespegs
0:00-1:38 The first version of the system had 2 sensors and 2 pumps. I cut 2 x 1 metre lengths of the mains cable and soldered one to each motor. IMPORTANT - this is not to plug them into the mains, I just find 2 core mains cable convenient. I covered the solder joints with electrical tape but you can use heatshrink if you want a neater finish! I soldered jumper wires to the other ends of the cables, so they can plug into the breadboard. At 1:38 I was trying to be clever by using only 3 jumper wires for the 4 cores of wiring from the mains cables, but it's easier just to use 2 jumper wires for each mains cable.
3:20 For each moisture sensor you want to build, cut a 1 metre length of 2 core mains cable, and take one 6-wide row of header pins. Solder one core to pin 1 of the header pins, and the other core to pin 6. TIP - I found these work better if you remove the 4 unsoldered pins from the plastic, so you just get 2 metal pins held a consistent distance apart by the plastic.
3:28 For each moisture sensor you want to build, take the mains cable with the header pins soldered to it, and solder 2 jumper wires to the other end of the cores. Wrap those solder joints in electricians tape or heatshrink them.
Your 'moisture sensor' is now assembled. For the watering_system_simplified, sketch, you'll need to build 2 moisture sensors.
Testing the Moisture Sensor
3:53 Plug the components into the breadboard, following the Fritzing file or the screen capture that I've attached to this Instructable. At this stage, you really only need to wire up the bit with the moisture sensor (the 2 blue wires represent the jumper wires on the end of the mains cable), the 1M and 10k resistor, and the jumper from the moisture sensor to the A0 analogue pin. USB power is sufficient to power the sensor circuit, no need to wire up the power supply yet.
6:55 Open the Arduino application on your computer. Open the example sketch called AnalogInOutSerial. Connect your Arduino to the computer via USB and upload that sketch to it.
7:09 Open the Arduino Serial Monitor and watch the first sensor value changing - it should change even if you touch the header pins.
7:52 Take two samples of the soil you'll use the system with. One sample should be dry, and represents the level of dryness where you want the system to start watering. The other should be wet. Watch the Serial Monitor and write down the values the sensor shows when wet and dry. Pick a value that is a little higher than the dry value, open the watering_system_simplified Arduino sketch, and on the line that says
const int threshold1 = 850;
replace 850 with that value. You can set threshold2 to the same value, but this doesn't have to be so precise as this will just be a water level sensor.
Assemble the electronics
10:30 Prepare the box: drill holes for the wires leading from the pump(s) and sensor(s). Drill holes in the lid for the indicator LED(s). If you're using a metal box, put gromits in the holes before feeding your wires through.
16:57 I used a piece of a metal bracket as a strain relief for the cables. That's optional.
17:17 Finish wiring the components on the breadboard as per the Fritzing file. Upload watering_system_simplified to the Arduino and stick the adhesive breadboard into the box. Connect the power supply and check that everything works. watering_system_simplified is set up for 2 moisture sensors and one pump, but the Fritzing file only shows one moisture sensor circuit to avoid cluttering the diagram. So you need to wire the bit with the 1M resistor, 10k resistor and moisture sensor twice. Connect the second one to the A1 pin on the Arduino.
The second video shows the best method of watering your plants with this electronic setup.
1:04 Drill a hole in the bottom of the tray that will hold your plantpots. The hole should be just big enough to allow the plastic nozzle (ie. from a washing machine tap adaptor) to fit through very snugly.
1:17 Place the nozzle through the hole and use a hot glue gun to seal the hole and melt the plastic around the nozzle. A piece of duct tape stuck over the nozzle from the inside of the tray seals the gap even better. You need to poke a hole in the duct tape to allow water to escape through the nozzle, though.
(not shown in the video) Fit a length of plastic tube on to that nozzle, long enough to reach the floor from wherever you'll put the watering system.
1:26 Place the cooling rack inside the plastic tray. This will keep the plantpots from sitting in any water that doesn't drain through the nozzle.
1:44 Take a 5 litre bottle, or another tray, and place it on the floor beneath where you placed the first tray. Insert the pipe coming from the nozzle in the first tray, into the neck of the bottle. Attach another metre of pipe to the pump outlet and place the pump in the bottle too. Place your plantpots on the cooling rack in the top tray and rest the end of the pipe coming from the pump on top of the plantpots. Poke holes along that pipe where it rests on the pots, so that water can run out into the soil. Take the sensor attached to A0 and push the header pins into the soil of one of the pots. Tape the other sensor part way up the side of the tray - it will act as a water level sensor. The small clamps or clothespegs will help at this stage, to keep the various pipes and wires in place.
Plug in the power adaptor. Once the soil dries out, the pump should feed water up the pipe until the soil is wet again. The water level sensor should prevent the water overflowing the tray. If the water reservoir runs dry whilst the pump is running, you may need a larger reservoir.
Later in the second video, I show how to add a larger pump running on mains power, but I'm not going include those steps here because I'm not going to recommend that you start messing around with mains power. That section of the video is for entertainment only!