-
Notifications
You must be signed in to change notification settings - Fork 1
Water Pump
David Salek edited this page Apr 13, 2018
·
13 revisions
A water pump can be used for automated plant watering.
The setup consists of the following components:
- watering pump (DC 5V, USB connector)
- relay switch
- USB connector board
The VCC and GND wires from the USB connector board go into the relay switch. This is how to connect Raspberry Pi pins:
- pin 2 (5V) to VCC on the USB connector board
- pin 6 (GND) to GND on the USB connector board
- pin 9 (GND) to GND on the relay switch
- pin 12 (GPIO 18) to SIG on the relay switch
- pin 1 (3.3V) to VCC on the relay switch
Set GPIO 18 for output:
echo "18" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio18/direction
Check the current value:
cat /sys/class/gpio/gpio18/value
Turn the pump on and off:
echo "1" > /sys/class/gpio/gpio18/value
echo "0" > /sys/class/gpio/gpio18/value
Release the pin in the end:
echo "18" > /sys/class/gpio/unexport
Install the python package for controlling GPIO pins.
sudo pip3 install RPi.GPIO
The pump.py script pumps water in case the moisture gets below a predefined threshold.
The moisture threshold and the pumping time are configured in raspberrypi.cfg.
In my experience, roughly 250 ml water gets pumped in 10 s.
Edit crontab
crontab -e
and add the following line to schedule automatic plant watering
30 * * * * cd /home/pi/plant_monitor_rpi && /usr/bin/python3 pump.py >> /home/pi/pump.log 2>&1