## Overview

The WATERMARK Soil Moisture Sensor measures electrical resistance inside of a granular matrix to determine soil water tension. Originally developed in the 1980's, many different methods and devices have been used to read the sensor both by IRROMETER as well as others.

To measure resistance inside the sensor, typically a voltage divider circuit is used. The circuit uses a known input voltage, output voltage, and series resistor value to calculate the value of another resistor (the sensor). Figure 1 is a simple example using a digital pin for power and an analog input to read and measure the resistance of the sensor.

Once the resistance is known, the value is calibrated to soil water tension via a series of equations or referencing look-up tables. The WATERMARK sensor can be read by devices such as Arduino/ Raspberry Pi etc., provided some guidelines are maintained with the reading circuitry and program.

For adapters which will read the sensor and output the values in a more standard format such as an analog 0-3V or SDI-12, click here.

R=10000*(Vs-A1)/A1

## Sensor Power

AC is the simplest excitation for reading WATERMARK sensors, as the alternating polarity prevents building a charge which both offsets the reading and degrades the electrodes over time. In cases where it is impractical to supply AC excitation, there are two options:

#### 1. Pseudo-AC Short Pulse

A "pseudo AC" created by alternating the current direction of a brief DC excitation for equal amounts of time. Output pins are alternated and isolated, with the second reading reversing the charge of the previous. This leaves the sensor with no accumulated potential, immediately ready for subsequent readings. The alternation can be done via switching the source and ground using additional hardware or by using a pin set low as the ground and switching the state of the two pins back and forth. As with the short pulse method, excitation should not exceed 50ms total and the measurement should be taken within 100us.

#### 2. DC Short Pulse

If DC current is applied without alternating the polarities, excitation should not exceed 50ms and the reading should be taken 100us to 200us after the excitation is applied. Delaying the reading beyond 200us with a DC source will build a charge offset on the sensor, changing the measured resistance and reducing the life of the electrodes. After reading, the leads should be shorted together or the powered side shorted to ground for 30 seconds to remove any accumulated DC potential in the sensor.

## Sensor Isolation

Devices reading WATERMARK sensors must isolate the sensor reading circuit from any earth ground. Mains powered devices will need transformer isolation to prevent a loop to ground through nearby equipment, and any communication line intended to be permanently connected to another grounded device will require optical isolation. If a ground loop exists, the readings will be wrong and current leakage may quickly destroy the sensor electrodes. Battery powered devices are more isolated by nature, but grounds for lightning protection etc. can cause the same problem.

In addition to general device isolation from ground, when reading multiple sensors the circuit must be designed to accommodate isolating sensors from each other. The wet soil in which sensors are installed creates a common conductive path between sensors. In effect, without isolation a device can be reading partially or fully between electrodes in different sensors rather than between electrodes inside each sensor.

Sensors must be powered individually, and the ground must be isolated from sensor to sensor. Even if powered individually, an open ground path to another un-powered sensor can't be allowed. This is best accomplished using multiplexers to open and close the appropriate channels.

Caution: Since WATERMARK sensors provide a direct path from earth to any device, protection via Zener or TVS diodes should be included on all sensor lines. In the interest of simplicity these are not included in any of examples to follow, but are highly recommended.

## Calibration

The Rx value is based on the amount of moisture inside of the sensor, but an additional calibration is necessary to relate the resistance to soil water tension. The most commonly used calibration equation is the one developed by Dr. Clinton Shock in 1998:

kPa= (-3.213*R - 4.093) / (1 - 0.009733*R - 0.01205*T)

where R is resistance in kOhms and T is temp centigrade. This calibration covers the range of 10 to 100 kPa. Typically linear extrapolations are used below 10 and above 100 kPa. Note that a fully wet sensor measures 550 Ohms.

The measured resistance in the sensor is affected by temperature. A default temperature of 24 C can be used in the absence of temperature data, but a temperature sensor input can be used for increased accuracy.

The calibration used in IRROMETER devices is based on this equation, and a table can be downloaded at the end of this document for reference. The sample program provided for the example below also contains an example calibration method.

## Arduino Example

The example below reads one soil temperature and three WATERMARK sensors using one 74HC4052 dual channel multiplexer. Two outputs are used to control the multiplexers (PWM3 and PWM4) while PWM5 and PWM11 are alternated as excitation power and GND. A1 is used for the analog measurement.

Initial Steps:

1. PWM 6 set LOW to enable multiplexer
2. PWM 3 and 4 are set to the appropriate channel

Direction 1:

1. PWM 5 is set HIGH for sensor excitation
2. A1 is read to measure resistance
3. PWM 5 is set LOW to end the reading

Direction 2:

1. PWM 11 is set HIGH for excitation
2. A1 is read to measure resistance
3. PWM 11 is set LOW to end the reading

PWM 3 and 4 are set to the next channel and the reading is repeated for the next sensor

Shutdown:

PWM 6 set HIGH to disable multiplexer

Calculate Resistance:

Where SenVWM1 is the analog voltage measured in the first direction, SenVWM2 is the same in the second direction, and Rx is the value of R1:

```					```
double WM_ResistanceA = (Rx * (SupplyV - SenVWM1) / SenVWM1); //voltage divider
double WM_ResistanceB = Rx * SenVWM2 / (SupplyV - SenVWM2);  // reverse
double WM_Resistance = ((WM_ResistanceA + WM_ResistanceB) / 2); //average the two directions
```
```

Convert to Centibars (kPa):

Where res is the measured resistance, TC is the soil temperature in C, and cF is an optional calibration factor:

```					```
int myCBvalue(int res, float TC, float cF) {   //conversion of ohms to CB

int WM_CB;
float resK = res / 1000.0;
float tempD = 1.00 + 0.018 * (TC - 24.00);

if (res > 550.00) { //if in the normal calibration range
if (res > 8000.00) { //above 8k
WM_CB = (-2.246 - 5.239 * resK * (1 + .018 * (TC - 24.00)) - .06756 * resK * resK * (tempD * tempD)) * cF;
} else if (res > 1000.00) { //between 1k and 8k
WM_CB = (-3.213 * resK - 4.093) / (1 - 0.009733 * resK - 0.01205 * (TC)) * cF ;
} else { //below 1k
WM_CB = (resK * 23.156 - 12.736) * tempD;
}
} else { //below normal range but above short (new, unconditioned sensors)
if (res > 300.00)  {
WM_CB = 0.00;
}
if (res < 300.00 && res >= short_resistance) { //wire short
WM_CB = short_CB; //240 is a fault code for sensor terminal short
Serial.print("Sensor Short WM \n");
}
}
if (res >= open_resistance || res==0) {
WM_CB = open_CB; //255 is a fault code for open circuit or sensor not present
}

return WM_CB;
}
```
```

Download the code for this sample as well as a simplified, single sensor example HERE