Never forget to water the plants again: building a DIY automatic plant watering / irrigation system for <$512 Nov 2020
Ok, trying something new here - as you might know, I have been having fun with home automation for a while now. Home Assistant is my platform of choice. I will start writing down the more interesting things I did to make my house "smarter" and publish them on this blog. This is the first of many (?) - we will see how it goes.
One thing we never seem to get right is when to water plants. We either overfeed them or forget them. In either case, they die quickly.
As part of my many home automation endeavors I wanted to build an automatic plant watering system.
The basic idea was: a water pump in a glass of water, a moisture sensor and whenever the soil the moisture sensor is measuring is dry, the water pump provides water until the soil is wet.
I found this kit of Aliexpress: https://www.aliexpress.com/item/4001096063867.html?spm=a2g0s.90423184.108.40.206e74c4dDfCE0X, which has almost everything you need. Almost.
I say almost, because when you assemble this kit it does the opposite from what you need. Basically, when the sensor reports the soil is wet, the motor turns on and when the soil is dry, the motor turns off. Update: after posting this I figured out you could also solve this issue by connecting to the NC instead of the NO of the relay.
Also, it is not very clear how you need to connect this kit to make it work.
See the original kit in action below:
Putting it together
Here is what I did:
- First, I used the USB cable that came with the kit to provide power (you can use another way of getting 5V of power)
- Then, I added a 2N700 transistor to build a simple inverter (see http://www.learningaboutelectronics.com/Articles/Transistor-inverter-circuit.php). It takes the input from the moisture sensor and provides it to the relay, effectively reversing the effect: when the soil is dry, turn on the pump, when the soil is wet, turn off the pump. You can use the small potentiometer on the moisture sensor breakout board to adjust sensitivity to moisture. You need a 1M Ohm resistor as well.
This is the circuit on a breadboard:
These are the connections:
- Moisture sensor: connect to two pin side of breakout board. Does not matter which way.
- Moisture sensor breakout board:
- VCC --> +5V
- GND --> GND
- D0 (digital output) --> input of 2N700 (middle)
- 2N700 inverter:
- Left --> GND
- Middle --> D0 (digital output) of moisture sensor breakout board
- Right --> 1M resistor --> +5V and to Input of relay
- VCC --> +5V
- GND --> GND
- IN --> Right output of 2N700
- COM --> +5V
- NO --> Red wire of water pump
- Water pump:
- Black --> GND
- Red --> NO of Relay.
This is the final setup (before making it look pretty with a case and longer wires):