Introduction: Automated Home Plant Care

Welcome to the Dill Project. In the video above I have a functioning prototype of my very own automated home plant care system. Below I explain what you will need for this project and how to put it all together.

Step 1: What Will You Need ?

  1. LED Grow Light, you can buy a very cheap one at Walmart.
  2. A small pump, no need to buy anything too big or expensive.
  3. A relay, I used an 8-channel, but a 4-channel might be preferred.
  4. A small set of screwdrivers and wire cutters/strippers to use the relay.
  5. A bucket for water AKA the reservoir .
  6. Seeds, soil and some sort of container for the plant. If you're just doing a small plant a solo cup might be your best option.
  7. A camera module if you want to add time-lapse capabilities.
  8. Moisture sensors, these can be found on amazon for fairly cheap.
  9. Jumper cables if you need them, the sensors typically come with enough though.
  10. A Raspberry Pi and you're ready to go!

Step 2: A Closer Look

Let's start with the Relay. The relay is going to enable you to connect to real world objects and allow you to control them from your Raspberry Pi. This is done by connecting the Relay to the Pi using the GPIO pins. In order to get the Relay to function you will need to hook it up to both a ground and 5v pin. After this connection is established you can use any of the relay switches by simply connecting any GPIO pin to a relay channel.

Now the next thing has to be setup in order to control this is on the other side of the relay. On this side of the relay you will actually be connecting the wires of the object you wish to control to the relay. This can be done by simply cutting the wire, then splitting the wire, and then using the screws on the relay to tighten them into the relay to create a solid connection. Once this is complete the relay will effectively act as a switch for the objects connected to the relay. This switch can be controlled through code written on your Pi and now you can take control of both the light and the pump.

Step 3: The Moisture Sensor

The moisture sensor is it at the center of functionality for this project. The sensor has two parts,one part that actually is stuck into the soil and another part that sits outside and has two LEDs. The left side of the sensor needs to connect with the GPIO on the Pi in three places. It needs power, it needs grounding and it needs a GPIO channel to read the signals transmitted by the sensor. I recommend using the 5V on the board as the 3.3V doesn't seem to give enough power for the sensor.

A little more on the sensor shall we? Things to know, if only 1 LED is on that means that the sensor is not detecting moisture and if both LEDs are lit then the sensor does detect moisture. These sensors are cheap, I bought 5 for $6 on Amazon so do not be discouraged if it is not working, there could likely be a hardware problem.

Step 4: The Code

The script that I wrote worked for my project, but you may have to tweak it slightly to better match what pins you chose. In addition to this I recommend using Python just because it is by far the most accessible language on the Pi itself. I have simply copy and pasted the code below, the formatting would not pass syntax.

import RPi.GPIO as GPIO
import schedule

import time from picamera

import PiCamera

#GPIO Objects

LAMP = 20

PUMP = 21

SENSOR1 = 10


#Pin Setup



#Individual Pin Setup







camera = PiCamera()

def lighton():

print("Good Morning!")




def lightOff():

print("Good Night!")




count = 0

def cam():

global count print("About to take a picture! Smile!")



camera.capture('/home/pi/images/image'+str(count)+'.jpg') camera.stop_preview() print("Got it!")





def callback(SENSOR1):

if GPIO.input(SENSOR1):

print("Turning the pump on.")



print("Stopping Pump")


def callback2(SENSOR2):

if GPIO.input(SENSOR2):




# This line tells our script to keep an eye on our gpio pin and let us know when the pin goes HIGH or LOW GPIO.add_event_detect(SENSOR1, GPIO.BOTH, bouncetime=300)

# This line asigns a function to the GPIO pin so that when the above line tells us there is a change on the pin, run this function

GPIO.add_event_callback(SENSOR1, callback)

#GPIO.add_event_detect(SENSOR2, GPIO.BOTH, bouncetime=300)

# This line asigns a function to the GPIO pin so that when the above line tells us there is a change on the pin, run this function

#GPIO.add_event_callback(SENSOR2, callback)

# This is an infinte loop to keep our script running while True: # This line simply tells our script to wait 0.1 of a second, this is so the script doesnt hog all of the CPU schedule.run_pending() time.sleep(6)