top of page

Capacitive Soil Moisture

This analog capacitive soil moisture sensor measures soil moisture by detecting the change in capacitance that stems from the moisture content of the surrounding soil. The output of the sensor is a voltage between 0V and 3V, with 0V being very dry soil and 3V being wet soil.

Capacitive Soil Moisture

This analog capacitive soil moisture sensor measures soil moisture by detecting the change in capacitance that stems from the moisture content of the surrounding soil. The output of the sensor is a voltage between 0V and 3V, with 0V being very dry soil and 3V being wet soil.


  • Don't place the sensor in soil or water past the white line

  • The sensor is powered from 5V

  • The JackBord is NOT waterproof, so don't allow it to become wet

How the Sensor Works

The sensor has an oscillator whose frequency is controlled by capacitance, and this capacitance is affected by the moisture content of the soil in which the sensor is placed. Under dry conditions the sensor's output will be 3V, and as the sensor gets wet the output voltage will fall until it reaches 0V. The type of soil will also influence the readings so some experimentation may be required.

Sensor Pins

The pins of the sensor are shown below. Note this is the top view. The pins are shown in order starting from the top and moving down.

The best wire color is included so you get into the habit of using consistent wires for the ground and power supply as this will save you a lot of trouble in the future.

Connecting the Sensor to the JackBord

To make using the sensor easier we have fitted some longer wires which may then be connected to the JackBord via the TOP terminals. So we first need to connect the TOP to the JackBord, then we need to connect the sensor to the TOP

Connecting the TOP

We will use the JackBord TOP to aid in connecting the sensor to the JackBord. The table below lists the connections we will make. See the pictures below for each step. The connections we will make to the JackBord are given below. The sensor's output will go to pin A1 which will be set as an analog input.

Follow these steps. First we will connect the various jumpers to the TOP, make sure that you have your TOP already mounted on the JackBord and that the power wires for the TOP have already been connected.

1. Turn off the JackBord

2. Connect the green jumper wire from ground on the TOP to pin 3 of the TER, this is the 3 pin terminal block at the top of the TOP.

3. Connect the orange jumper wire to TER pin 2, then connect the other end to Port A1. This is the analog output from the sensor.

4. Connect the red jumper wire to the TER pin 1 and the other end to one of the +5V power pins on the top right of the TOP. This will supply power top the sensor. Once you have made the connections check them against the picture below and make sure they match.

Now that the TOP is connected to the JackBord we need to connect the sensor to the TOP. Follow the steps below.

Connecting the Sensor to the TOP

To connect the sensor to the TOP via the terminal follow these steps. You will need a Philips screwdriver for this step to tighten the screws on the terminal block. DO NOT TIGHTEN THEM TOO MUCH.

1. Get the sensors black wire and insert it into the lower hole on the terminal block as shown below, this is TER pin no 3. Tighten up the screw by turning it clockwise. You should not be able to easily pull the wire out of the terminal.

2. Get the sensors yellow wire, this is the analog output wire, and connect it to the second terminal block slot as shown below, this is TER pin no 2.

3. Connect the sensors red wire to pin TER 3 of the terminal block. This is the 5V power supply from the JackBord to the sensor, this is TER pin no 1.

Check your connections, they should look like the picture below. Also make sure the terminal block screws are tight enough, but not too tight.


Using the Sensor with the JackBord

Now that the sensor is connected to the JackBord turn it on and log into your dashboard. A convenient way to represent soil moisture is as a percentage where 0% is very dry and 100% is saturated. But the sensor is the opposite, it puts out 0V for wet and 3V for dry. Thus we need a way of scaling the readings between 0% for dry and 100% for wet.

The gvr command will let us get the voltage reading from pin A1 and scale it between 0 and 100 such that the reading will increase with increasing moisture. At the command prompt, type the command below:

gvr a1 100 0

This turns pin a1 into an analog input and tells it to scale the voltage readings so they are in the range 100 to 0, where 100 = 0V and 0 = 3V, remember the sensor puts out 0V for high moisture, which we want to be 100%. This is why the 0 and 100 in the gvr command are the opposite way around to what they would normally be. Go to the LIVE page and you should start to see readings from the sensor.

Note: It does take a sensor a while to register an increase in soil moisture so don't be surprised if it takes between 20 and 30 seconds to respond.

Testing the Sensor

In Dry Air

First get a reading for dray air, i.e. the sensor is by itself. This will be between 0 and about 10. Ours was 6.

In Water:

Now get a glass of water and place the sensor in it, be careful the water does NOT go past the line on the sensor, as shown below: BE CARFUL not to get the electronics wet.

Now look at the live page and you will see the reading is about 50 to 60, yours will vary but should be about this. Ours was 57.

We now have our two extreme readings, these tell us the minimum and maximum values we can expect from the sensor. Now its time to do some tests in soil and see how the sensor responds.

In Dry Soil:

Get a glass and put some dry soil in it. Make sure the soil level is high enough to reach just below the white line on the sensor. Now look at the readings and see what you get. For ours we got a reading of 18.

In Moist Soil:

Add some water to the soil, to just wet it but not soak it. Check the reading from the sensor, ours was about 33.

In Soaked Soil:

For this one add enough water that all of the soil is completely wet but there should NOT be pools of water at the top. Take a reading, ours was 57.

In Flooded Soil:

This is the last case and for this we add water such that there are pools of it at the top of the soil. This represents the maximum amount of water we can possibly get into the soil. Take a reading, ours was 58 which is about right.

Dry Air Reading:

Remove the sensor from the wet soil and clean it. Then check the reading has returned to its previous dry air value of about 6.

Final Table of Soil Moisture Readings from the Sensor

The table below lists the calibration values we got from the sensor. Yours will differ, this can be caused by things like the type of soil etc.

Final Calibration Values:

The final calibration values we got for our sensor are:

These values will be used to set the initial values of the /min_value and /max_value variables in the basic soil moisture program below.

Project: Portable Soil Moisture Meter

Once you have completed the above and got the sensor working properly, you can use the Basic Soil Moisture Meter Program to turn your JackBord into a stand alone soil moisture meter that will display the soil moisture reading as the color of the USER LED on the front of the JackBord.

Run the Program Automatically on Start Up:

If you want to have the soil moisture program run on boot use the setboot command to have the JackBord run the soil moisture meter program after its turned on. For example if your program is in program no 8 on the PROG page you would type:

setboot 8

From now on the program will run when the JackBord is turned on. To stop running it automatically type:

setboot 0

By default the program will take 100 measurements and then exit, to disable this and have it run continually coment out the line below in the code:

any /count >= 100 -> exitprog

bottom of page