Soil Moisture Monitoring with Raspberry Pi

As described in previous posts, I have a self-watering setup with an extended reservoir. The only problem that has come up is that after some time the supply lines become blocked with a biofilm. When that happens, the larger plants can quickly dry out, and any fruiting going on is affected, either by reduced flowers, aborted fruit, or stunted growth.

IMG_20141007_214321This was a great excuse to buy a Raspberry Pi, and learn how to play with electronics. There are already a couple of great guides that I referenced when putting everything together, particularly Jeremy Blythe’s tuts+, and Devon Bray at Although the MCP3008 wiring didn’t work out for me from Jeremy’s tutorial, this one worked for me. I won’t go into the details of all the assembly since it’s well covered elsewhere. I will go into detail about things I did different though.

IMG_20141005_092830For the actual moisture sensors, I purchased a 10 pack off of ebay, they are all pretty much the same. They’re a little over $1 each. Reading about others experience with these corroding quickly in soil, I took a recommendation to put the sensors into plaster of paris. For the mold, I actually reused the anti-static packaging each moisture sensor came in. Filled it full of the plaster mixture and placed it between two objects to keep it upright, and inserted the moisture sensor into it. After an hour, use scissors to cut off an edge, and peel the mold off. Allow to cure for 24 hours.

For the code mentioned below please see my Github.

IMG_20141007_214335Another measure to slow down corrosion is to only supply power to the sensors when you are taking readings. To accomplish this, I connected the power rail on the breadboard that supplies the power to the sensors with the power from GPIO 7 on the Raspberry Pi. That way I can turn it on when I am taking a reading. For a consistent reading, I gave 1/10th of a second after turning the GPIO on before taking a reading and 1/10th of a second between each sensor readings. This allowed the power levels to even out.

While I like having a readout with an LCD, I didn’t care to have it rotate constantly. Plus I only want readings every 10 minutes, so it’s not like the data will be instant. I set the buttons (any button) on the lcd panel to cycle through each of the pot moisture readings and then clear itself.

While having values available locally is nice, what is even more valuable is seeing the values change over time. I found as a fast and easy way to get data into a chart form and keep it updated. The chart I am publishing data to is publicly available for viewing.

I haven’t decided whether I want to extend this to alerting me by some means when moisture content drops to a certain level, but now that all the hardware is setup, the code is trivial.

Leave a Reply

Your email address will not be published. Required fields are marked *