I love house plants, but I can’t seem to keep them alive. I decided to utilize a Raspberry Pi to monitor soil moisture and re-water the plant automatically, sending alerts when the water reservoir is empty, and providing a web service that updates my home page with the latest photo (hourly).
I wanted to make this as automated as possible. Utilizing the all-knowing Google, I have scoured the web and pieced together this Rube Goldberg device. Here’s a diagram of the basic layout:
How it’s built:
The heart of the system is a Raspberry Pi 2 Model B. This is an amazing computer about the size of a pack of cards that only costs $35. It packs some amazing features for that price:
- Broadcom BCM2836 ARMv7 Quad Core (900mhz)
- 4 USB ports
- 40 GPIO pins
- Full HDMI port
- Ethernet port
- 3.5mm audio jack and composite video
- Camera interface (CSI)
- Display interface (DSI)
- Micro SD card slot
- VideoCore IV 3D graphics core
To start with, I needed to detect the moisture level so that I could determine when the plant needs watering. For this, I connected an Arduino compatible High Sensitivity Moisture Sensor. This provides an analog voltage representing the soil moisture, so it has to be converted to a digital value for use on the Raspberry Pi.
To convert the analog voltage to a digital value, I used an Adafruit 8 Channel 10 Bit Analog ADC for Raspberry Pi. This can be connected directly to the sensor and Raspberry Pi. I’ve just used a breadboard for this, but I’ll probably create a more permanent solution later.
Next, I needed a way to automatically water the plant. I needed to pump water from a reservoir whenever the plant moisture level dropped too low. I found an inexpensive pump on Amazon (Lightobject EWP-DC30A1230 Mini DC Brushless Submersible Water Pump), but I needed a way to control it from the Raspberry Pi. For that, I added a relay (SunFounder 2 Channel 5V Relay Shield Module).
I wanted to make sure that the water couldn’t overflow the plant onto the carpeting. My solution was to use a deep saucer under the plant that not only catches the excess when the plant is watered, but also serves as the reservoir for the pump. In this way, even if the pump continuously runs, the water pumped will be safely returned to the reservoir. I also decided to just use a 9v battery as the power source for the pump, so it would not be able to run indefinitely in case of a malfunction.
Finally, I needed a way to check the water level of the reservoir. So, I added another Moisture sensor and used another channel on the A/D converter to monitor that from the Pi.
I added the Pi camera so I could monitor my plant and view its beauty from anywhere on the web. (picture is updated hourly, between the hours of 8:00 AM and 5:00 PM)
For the final step, I linked the Pi to my web site, so I could view the plant, and see the latest watering information:
This is a a picture of the actual construction. Everything is just connected via a breadboard, for now.
How It Works
To start with, I don’t like Python, which is the de facto standard language on the Pi. The indentation rules are just wrong. My opinion. But since my Pi runs Raspian (a Linux version based on Debian), it runs a C compiler just fine. So, C it is.
I wrote a daemon which starts at boot time to control the whole system. Every hour it checks the moisture level in the plant, and the level of the reservoir. If the plant needs watering, it turns on the relay for a few seconds so the pump will water the plant. If the reservoir is empty or low, it will send me an email so that I know to refill it. At the same time, it takes a picture of the plant to record its current state.
I also wanted a way to monitor my one-plant garden from the web. Since the Pi runs Linux, I was able to install an Apache web server and PHP on the Pi. I wrote a REST service to return the watering status as a JSON string. I opened a port on my router to forward the web service requests to my Pi.
My web site, which runs ASP.NET and is written in C#, calls this REST service to get the latest watering information, which it displays on the web site, along with the latest plant picture from the Pi camera.
Sample Log Entries:
It remains to be seen if all of this technology can succeed in keeping my plant alive. I have a pretty good track record of killing houseplants (unintentionally). I’m crossing my fingers.
Update: Sep 3, 2015
Electrolysis has taken its toll on the Arduino sensor. The voltage level started dropping quickly, due to the corrosion of the probes. I’ve attached a picture showing the damage:
So I’ve scoured the web for a cheaper and easier to maintain solution, and came up with this. It is comprised of two galvanized nails, separated by a Styrofoam block, connected to the ADC with a 10k Ohm resistor in series on the ground wire. So far it seems to be working well. I’ve attached the leads to the nails by alligator clips, so when they corrode, I can simply insert new nails into the Styrofoam, and reattach the clips. Here’s a picture of the new sensor: