Introduction: Soil Moisture Sensor Calibration

About: Finding a simple solution to a problem.

There are many soil moisture meters on the market to help the gardener decide when to water their plants. Unfortunately, grabbing a handful of soil and inspecting the colour and texture is as reliable as many of these gadgets! Some probes even register “dry” when dipped in distilled water. Cheap DIY soil moisture sensors are readily available in places like Ebay or Amazon. Although they will give a signal according to the soil moisture, relating the sensor output to the demands of the crop is more difficult. When deciding to water your plants, what really matters is how easy it is for the plant to extract water from the growing media. Most moisture sensors measure the amount of water in the soil rather than whether the water is available to the plant. A tensiometer is the usual way to measure how well the water is bonded to the soil. This instrument measures the pressure required to remove the water from the growing media, common units of pressure used in field work are millibar and kPa. For comparison, atmospheric pressure is about 1000 millibars or 100 kPa. Depending on the plant variety and type of soil, plants can start to wilt when the pressure exceeds about 100 mIllibars.

This Instructable describes a way of calibrating a cheaper and more readily available moisture sensor against a DIY tensiometer. Although this could be done manually by plotting the results on paper, a simple datalogger is used and the results posted on ThingSpeak. The method can be used to easily calibrate a soil moisture sensor to a tensiometer reference so that the gardener can make informed decisions on when to irrigate, save water and grow healthy crops.

Supplies

The parts for this Instructable are easily found by searching sites like Amazon or Ebay. The most expensive component is the MPX5010DP pressure sensor which is available for less than $10. Components used in this Instructable are:

Capacitive soil moisture sensor v1.2
ESP32 development board
Tropf Blumat ceramic probe
NXP pressure sensor MPX5010DP or MPX5100DP
Rubber stoppers
6mm OD clear plastic tube
2 100K resistors
1 1M resistor
Connecting wires
Plant pot with compost
Boiled water
ThingSpeak account
Arduino IDE to flash ESP32
Access to internet connected WiFi




Step 1: Tensiometer


A soil tensiometer is a water filled tube with a porous ceramic cup at one end and a pressure gauge at the other. The ceramic cup end is buried in the soil so that the cup is in close contact with the soil. Depending on the soil water content, water will pass out of the tensiometer and reduce the internal pressure in the tube. The pressure reduction is a direct measure of the soil affinity for water and an indicator of how difficult it for plants to extract water.

Tensiometers are made for the professional grower but tend to be expensive. Tropf-Blumat manufacture an automatic watering device for the amateur market which uses a ceramic probe to control the irrigation. The probe from one of these units can be used to make a tensiometer costing only a few dollars.

The first task is to separate the plastic diaphragm from the green head of the probe. It is a pop fit into the green head, judicious cutting and snipping will separate the two parts. Once split apart, drill a 1 mm hole in the diaphragm pip. The plastic pipe is connected to the pip on the top of the diaphragm for pressure measurements. Warming the end of the tube in boiling water will soften the plastic to make fitting easier. Alternatively, a traditional bored rubber stopper could be used instead of recycling the diaphram. The pressure in the probe can be measured directly by measuring the height of a water column supported in a U tube. Each inch of water supported is equivalent to 2.5 millibars of pressure.

Before use, the ceramic probe must be soaked in water for a few hours to wet the ceramic thoroughly. The probe is then filled with water and the stopper fitted. It is best to use boiled water to prevent air bubbles forming inside the probe. The probe is then firmly inserted into damp compost and left to stabilise before measuring the pressure.

Tensiometer pressure can also be measured with an electronic pressure gauge such as the MPX5010DP. The relationship between pressure and output voltage from the gauge can be found in the sensor data sheet. Alternatively, the sensor can be calibrated directly from a water filled U tube manometer.

Step 2: Capacitive Soil Moisture Sensor

The capacitive soil moisture sensor calibrated in this Instructable was the v1.2 readily and cheaply available on the Internet. This type of sensor was chosen over the types that measure soil resistance because the probes can corrode and they are affected by fertiliser. The capacitive sensors work by measuring how much the water content changes the capacitor in the probe which in turn provides the output voltage of the probe.

There should be a 1M resistor between the signal and ground pin on the sensor. Although the resistor is mounted on the card, sometimes the ground connection is missing. Symptoms include slow response to changing conditions. There are several work arounds if this connection is missing. Those skilled in soldering can link the resistor to ground on the board. Alternatively, an external 1M resistor can be used instead. As the resistor discharges a capacitor on the output, this could be achieved in software by shorting the output pin momentarily to ground before measuring the sensor.

Step 3: Data Logging

The tensiometer and capacitive probe are firmly placed together in a plant pot containing wet peat compost. A few hours are needed for the system to settle and give steady readings from the sensors. An ESP32 development circuit board was used in this Instructable to measure the sensor outputs and post the results to ThingSpeak. The circuit board is widely available from cheap Chinese suppliers and several of the pins can be used for analogue voltage measurements. As the pressure sensor outputs a 5V signal, this voltage is halved by the two 100K resistors to avoid damaging the 3.3V ESP32. Other types of sensor can be connected to the ESP32 provided the output signal is compatible.

Finally, the plant pot is allowed to dry out naturally and the sensor readings posted every 10 minutes to ThingSpeak. As the ESP32 has spare GPIO pins, other sensors like temperature and humidity can be added to give further information about the environment.

Step 4: ESP32 Program

You will need to set up your own ThingSpeak account if you do not have one already.

The Arduino IDE sketch to measure the sensor outputs and post them to ThingSpeak is shown below. This is a very basic program with no error trapping or progress reporting to the serial port, you may like to embellish it to your needs. Also, you need to insert your own ssid, password and API key before flashing to the ESP32.

Once the sensors are connected and the ESP32 powered from a USB power supply, readings are sent to ThingSpeak every 10 minutes. Different read times may be set within the program.

DATALOG SKETCH

#include <WiFi.h>
WiFiClient client;
void setup() {
WiFi.mode(WIFI_STA);
connectWiFi(); 
}  
void loop() { 
  if(WiFi.status() != WL_CONNECTED){    
connectWiFi(); 
    } 
 client.connect("api.thingspeak.com", 80);
   
float pressure = analogRead(34);
float cap = analogRead(35);
pressure = pressure * 0.038; //Change to millibar
delay(1000); 
String url = "/update?api_key=";   // Build string for posting
    url += "Your API key";
    url += "&field1=";
    url += String(pressure);
    url += "&field2=";
    url += String(cap); 
         
      client.print(String("GET ") + url + " HTTP/1.1\r\n" +
                 "Host: " + "api.thingspeak.com" + "\r\n" + 
                 "Connection: close\r\n\r\n");
  delay(600000);                       //Repeat every 10 mins
}
void connectWiFi(){     
    while (WiFi.status() != WL_CONNECTED) {
       WiFi.begin("ssid","password");
       delay(2500);
    }    
  }

Step 5: Results and Conclusions

The ThingSpeak plots show the sensor readings increasing as the peat dries out. When growing plants like tomatoes in peat, a tensiometer reading of 60 millibars is the optimum time to water the plants. Instead of using a tensiometer, the scatter plot says that the much more robust and cheaper capacitive sensor can be used if we start irrigation when the sensor reading reaches 1900.

In summary, this Instructable shows how to find the irrigation trigger point for a cheap soil moisture sensor by calibrating it against a reference tensiometer. Watering plants at the correct moisture level will give a much healthier crop and save water.

Fix It Contest

Participated in the
Fix It Contest