Introduction: Raspberry Pi Grow Box

Hello! Thank you for stopping by. This page represents the final report necessary for one of my electronics classes at community college. For our project we were tasked to come up with a creation based on the Raspberry Pi, a tiny affordable microcomputer which uses Linux operating systems, features a 40-pin General Purpose Input / Output interface, HDMI output, ethernet port, wireless Network Interface Card, Camera interface, and many customizing options! The modern hobbyist can find a rich and diverse creative environment in the raspberry pi, with many projects and code repositories to choose from, coupled with the open-source community atmosphere of Linux. The pi is intended as an educational resource aimed at introducing folks of all ages to the world of technology!

I've always appreciated practical applications, so I decided to build an indoor plant nursery for my project. In the following guide I attempt to cover all the bases in a straightforward and sectioned-out manner. I did look at some other projects for reference, but I largely designed the box and the main program myself. Note that this is the first project I've designed and produced! My skills in carpentry are non-existent, so please bear with the crudeness of how my project turned out. I'm already thinking up ways to improve on it, but always welcome to suggestions. So lets get down to business!

Many of the photos contain detailed additional information. Don't neglect these!


This list is a general outline of the tech and materials you may need for your version of this project. Exact amounts or device versions may vary based on your interpretation. I used a Raspberry Pi 3.


  • Raspberry Pi
  • Wire Strippers
  • Corded Power Drill
  • Hole Saw (For Fan Ports)
  • Some coding experience is helpful
  • Jumper Wires (like this and Dupont Female-Male)
  • Some experience or knowledge measuring dimensions.

  • Basic understanding of electronics, Ohms Law, Power calculations.

Construction Materials


Adafruit MCP3008 8 Channel Analog-Digital Converter

Gikfun Capacitive Moisture Sensor

Adafruit DHT11 Temperature/Humidity Sensor

Submersible Water Pump (I used 12v Pump)

Computer Fans (DC)

4 Channel Relay Switch

Adjustable Buck Converter

Light Source (I used 24v LED)

DC Power Supply (I used 24V 10A)

The above supply will need an AC power cord

Breadboard (Protoboard)

Misc. Plant Materials

A planter/plastic container for growing desired flora

Potting Soil

Step 1: Planning

The first step to any great process is the planning beforehand. Take the time to visualize how wide, how high, how long your intended grow box will be. How many plants do you want to grow? how tall will they be? I found it helpful to sketch out my intended dimensions. I went with 3ft wide, 2ft long, about 3.5 ft tall for starters. The way that I constructed the frame resulted in the actual dimensions of the box being less than these figures. Just make sure to measure and re-measure for best results when sizing the walls, ceiling of the box.

The next thing to think about and plan would be your water reservoir placement, how will you get the water to the flower pot? I used a 12V, 1.5A pump which could handle the volume with a 5/8 outside diameter tube, and was able to push it up about 1.5 ft effortlessly. There are some tricks you can try such as using a smaller tube, or a gravity-driven arrangement.

Next, think about how you will arrange the wiring. I used a hole-saw to drill holes on the floor of the flower cabinet, as well as the reservoir-facing side of the tech cabinet. I fed the water pump wiring, the sensor wiring, and the light source wiring through these holes. I also made a hole for the pump tubing, to minimize the travel distance of the water.

Step 2: Calculate Your Power Supply Needs

After you've decided on the dimensions of your grow box, think about the tech you're going to use and how you'd like to power it. Depending on your choices for light source and fans, you may require AC power, DC power, or a mix of both. I didn't really like the idea of high-voltage AC power from the wall being dispersed in a small area likely to be spill-prone, so I opted for devices that would run on lower-voltage DC power.

sketch out a list of all the electronic equipment required for the box. Lights, fans, water pump, raspberry pi. Look at the power consumption information that usually comes with electronic devices. These devices need a specific voltage and current to operate. You want a power supply that can provide enough voltage to power the highest voltage requirement. The power supply needs to be rated well above the total current that all the devices could draw if they all ran at once.

So I figured out that I was going to be drawing about 6A from the supply at max. Out of the devices I was powering, the lamp required 24v, the water pump and the computer fans all needed 12v. This meant that I needed a supply that could provide exactly 24v and rated for 10+ Amps of current, for starters. It's just good practice to get a supply that's rated at least 1.5 times your required current (Amperage) draw.

The 24v supply is not appropriate to power the 12v appliances without support. Driving more voltage to the devices than what they require can result in serious damage to the device, potential fire hazard, and is just not cool. When I first picked up my 12v pump, I didn't have any means of providing 12v, but I did have a 14v power tool battery. So I began testing the pump with the 14v battery. The pump at first operated without indication that anything was wrong. It drove the water at a high rate of speed, could drain the 5 gallon pail in 2 mins! One time I had the wires in my lap while I was testing the placement of the water pump. I started to smell smoke, and I noticed the wires connecting power to the pump were beginning to melt through the casing! This could have led to situations where at the least, I would have a defective pump, with open wires underwater, inevitably connected to 110v wall socket. uhhh no thanks! make sure to only supply the exact voltage a device needs.

In my case, I only needed two voltages, 24 and 12. A search online introduced me to something called a Buck converter. I picked up two of these from amazon for a decent price. The buck converter has a maximum input voltage, and can step down that voltage within a certain range. A buck converter also has a current limit, measured in Amps (A). The ones from the link above were perfect, in the voltage range and rated for 5A. My pump required 1.5A and my fans about 1.25 collectively (I had 4).

Step 3: Construct the Box

Now that you've taken your measurements, have found the required building materials, cut your lengths to size, and have some rough idea of how things are going to look, its time to build it! I chose wood as my chief building material, because it's readily available and cheap. A good understanding of dimensions and measurements is helpful to save money in picking out materials. The people at the store were willing to cut my lumber to the lengths I needed. It's helpful when you have this information before you arrive. Look for a sheet or length of lumber that will let you get a few sides of the box from one cut. I was able to get my walls from one 4x8' sheet of plywood and a smaller one that was pre cut.

I picked up 2 or 3 2x3" 8ft lengths for my studs/framing. If using wood, Pre-Drill Every Screw. I used 4 L-Brackets to secure the floor of the box to the framing lengths. I'm not a carpenter, so I may have overdone it on the screws, and the box and frame has that down-home DIY look to it. Make sure the wood is as connected as possible and stays in even contact as you screw pieces together. It isn't a big deal to unscrew and readjust if you find that pieces move out of place or get crooked in the process. Once you've got the box constructed, you can begin to create portholes for your wiring and the water tubing.

In the photos above, You can see how I created the frame. I chose to place the water reservoir inside the frame, under the flower box. The height off the ground was determined so the bucket could be removed/replaced easily. Some leftover lengths of the 2x3 made a decent post for the water tubing, and provided some additional center support for the box floor.

Step 4: Create the Wiring and Plumbing Scheme, Wire Up Your Devices, Orient Them on the Box.

Now that you've gotten the box constructed, have anticipated where the wiring will go and how the water will get to the plant, It's time to start building the wiring network. Use terminal connectors to secure the wiring, combine devices, connect them to the power supply or buck converter, and the relay switch. Detailed explanations with pictures of setting up the converter and the relay switch, power supply will follow.

  • Orient and secure the plumbing with hose clamps, conduit clamps.
  • Begin to connect your fans, lights, and pump wiring to terminal connectors secured to box. (PRE DRILL EVERYTHING!)
  • Use zip ties, cable staples, electrical tape, to keep wires orderly and away from water.
  • Place the power supply, converter, relay switch, raspberry pi, breadboard, in an area protected from the potential of flooding or splashing.
  • Find a spot to place the raspberry pi, where it will be able to connect GPIO pins to the relay switch, and provide power to the sensors/breadboard.

Step 5: (Step 4.5)Wiring the Relay Switch, Power Supply, BreadBoard, ADC Converter, and PI

Please view all the pictures on this step to gain an understanding of how my project was wired.

  1. Want a deeper dive on relay switches? see this instructable:

  2. The Pin out/guide for Adafruit MCP3008 ADC

  3. See the GPIO HEADER quick reference picture for Pi wiring

The power supply I purchased supposedly has overcurrent protection built-in. The relay switch is also opto-coupled, meaning the Pi is isolated from the voltages on the other side of the relay. Both the Pi and the power supply are plugged into a surge protector.

Step 6: The Programming (pt 1)



By now, you should be ready to start writing the program that will control the GPIO pins on the raspberry pi. For this I used python 3/thonny pi idle. verify your python version with this in terminal:

python3 --version 

If you did not have it installed, try these commands from terminal:

sudo apt-get install python3-dev libffi-dev libssl-dev -y
tar xJf Python-3.6.3.tar.xz
 cd Python-3.6.3 ./configure make sudo make install sudo pip3 install --upgrade pip
apt-get update


The following library is reported deprecated, however you should still be able to pull the library down to the pi. Without this library the supplied code will not work.

Follow the instructions towards the bottom of the page, inputting each command into terminal. When complete, the dht11 sensor library will be accessible by your control program. The directory should come with examples, I copied the code for reading the sensor directly to my program, and created a function to call on it.


You'll need to get the library for the mcp3008 if thats the ADC you went with. The code I'm going to supply in the following step will use this library. Without this library the supplied code will not work.

The above is a useful guide for finding and turning on the SPI interface, which is used with the ADC chip. This is why we connected the ADC to those specific pins on the Pi. When you get about half-way through step 2, after "unblacklisting" you can stop after the first reboot instruction. Then you want to go to:

and follow the instructions from "Installing from PyPi" for a system-wide install. When that is complete, You'll be able to see some example python scripts in the directory, which call information from the ADC. For my program, I copy-pasted the "single ended mcp3008" code exactly, and created a function that read the values.

Take your time, be patient, and check your spelling/details when installing these. This is what it's all about.

When you've successfully downloaded the libraries and dependencies needed for interacting with the sensors, take the time to try to interpret what the code is doing. The examples provide some great comments to help you.

When you're sure the sensors are reading, lets move on to the last step!

Step 7: The Programming (pt 2)

Thank you so much for sticking it out with me all the way to step 7! Please leave any relevant reflections on this guide in the comments section.

Putting it all together: The control program

Well done you! we're finally here. You've designed the box, purchased the supplies, constructed the design, wired up the connections, installed the relevant libraries, and now you finally have a complete system to care for your small plants. Now you're finally ready to think about how you want the system to operate.

So, I'll give you the code I'm using to operate mine. I want to preface it by saying that I learned about python "the hard way" meaning that I fiddled around with it until I gained some understanding based on my previous knowledge with C programming. While C and Python are vastly different, the elements of coding are the same. I'm appreciative of any ways we can make this code simpler, or more effective.


This code will work if and ONLY if you followed the wiring instructions diligently, and installed the specific libraries I gave for these sensors. This code calls on specific pins to operate. If you did not wire the GPIO exactly as I did, it may not work without making adjustments. Just leave a comment and I'll try my best to take a look, if you experience issues.

I made two files--A and Make sure they're in the same folder when you run


config contains all the functions being called into the main program, Config and plant system both import all the same libraries to pull info from the sensors. Since they both have the same imports, either config or plantsystem can be run on their own. The following functions can be called in config in a live setting:

Read_report(): prints the time of day when function was called, and reads information from all sensors. The sensor information is manipulated, such as converting the Celsius reading to Fahrenheit, and calibrating the range for the moisture sensor.

Fans_ON(): Sends a 0 (LOW) to the relay channel which controls the fans.

Fans_OFF(): Sends a 1 (HIGH) to the relay channel controlling the fans.

Lights_ON(): Sends a 0 (LOW) to the relay channel which controls the lights.

Lights_OFF(): Sends a 1 (HIGH) to the relay channel which controls the lights.

Pump_ON(): Sends a 0 (LOW) to the pump relay channel. This function is designed to only run for 4 seconds before the pump turns off. Change that if you need to. in my setup, 4 seconds is as brave as i get!

setup(): configures the GPIO pins for input/output, performs GPIO.cleanup, defaults the devices to "all off" good for resetting the pins before shutdown. The runs this automatically on start.

There are other functions available from the libraries imported, but these are the ones I designed for the program.

Stay tuned for a video where I'll walk through the code I developed. For now, see if you can interpret it yourself. If statements control the pins. The lights are set to stay on for the first 16 iterations of the for loop. The for loop is intended to simulate a 24 hour timer.