Raspberry Pi Soil Moisture Sensor

Agriculture consumes between 80 – 90% of all freshwater in the United States. An easy way to conserve water in the agricultural sector is to install a soil moisture sensor. Soil moisture sensors measure the amount of water in the soil to maintain consistent and ideal soil conditions for plants. In some cases, installing a soil moisture sensor reduces residential irrigation by as much as 50%.

The following is a simple capacitive soil moisture sensor using a Raspberry Pi and a co-planar capacitor from the Zero Characters Left blog.

Raspberry Pi Soil Moisture Sensor

Excluding the Pi, the system can be built for less than $25.

Here’s a tutorial on how to control an outdoor irrigation valve to automatically water your plants when the soil is dry.

Step 1: Materials

Raspberry Pi
This tutorial is based on a fully set-up Raspberry Pi, including GPIO libraries + GPIO cable w/ breadboard connector. I also recommend setting it up for wireless + SSH.

Other microcontrollers, like an Arduino, also work.

— 1 MOhm resistor

This resistance was the best for my system, but a different resistor value might work better for your own setup. Experiment w/ different value resistors and see what happens!

— Co-Planar Capacitor

Save the two EAGLE files (schematic and board file), then send to OSHPark. It costs ~ $10.00 for three.

— Solid core or stranded 22-gauge wire

Recommended to get stranded wire b/c conducts better & is less likely to break.

— Breadboard, breadboard wires + GPIO breadboard converter

This is the bare minimum needed to build & test the system. If you want to install it outside after it has been tested and confirmed to work, coat everything in epoxy! …Although a better way might be to replace the breadboard w/ a PCB board. Molex connectors are also a nice addition.

Step 2: Tools

Soldering iron, solder & solder-sucker (or solder wick)
A soldering iron is (almost) essential for this project, especially for attaching wire leads to the co-planar capacitor. You can purchase a soldering iron, solder and solder wick (removes solder) for ~ $20-30, or find a local makerspace/hackerspace that will let you come in and use an on-site soldering iron.

— Wire Strippers

— Epoxy

— Optional (but highly recommended): Multimeter (for testing and debugging!)

Raspberry Pi Soil Moisture Sensor

Step 3: Sensor & Circuit Design

An RC circuit provides a quick & simple way to measure changes in the sensor capacitance due to changes in soil water content.

Every RC circuit has an associated time constant, which is the time it takes the capacitor to reach ~ 63% of its maximum charge. The time constant equals the total circuit resistance times the circuit capacitance: τ = R * C

The time constant is used to measure changes in the sensor capacitance due to changes in soil water content. As the water content increases, the capacitance increases causing the associated circuit time constant to increase. The Raspberry Pi GPIO Pin 14 measures, or counts, the circuit time constant (how long it takes the capacitor to charge).

 

For more detail: Raspberry Pi Soil Moisture Sensor

Scroll to Top
Read previous post:
Interfacing hex keypad to 8051

Hex keypad. In an 8051 microcontroller, it requires 12  cycles of the processor clock for executing a single instruction cycle....

Close