Soil moistures probes are based on 3 classical technologies:
- resistive probes
- capacitive probes
- tensiometer probes
Each technologiy has advantages and drawbacks.
- resistive probes wear down when using as their electrodes will destroy with electrolysis when current is passing through them
- tensiometer probes are probably more precise but more expensive. They also need more maintenance
- finally capacitive probes are the most commun as they are cheap, quite precise and do not destroy during time
Have a look at this page for more informations.
I decided to build a capacitive probe which will use the embeded "touch pad" sensors of ESP32 MCU.
Indeed a capacitive soilmoisture sensor is no more than a capacitor composed of a positive plate, a negative plate and the gap between the plates known as di-electric.
A capacitive moisture sensor works by measuring capacitance changes caused by the changes in the dielectric. It does not measure soil moisture directly (as pure water does not conduct electricity well), instead it measures the ions that are dissolved in the moisture. Capacitive measuring basically measures the dielectric that is formed by the soil and the water is the most important factor that affects the dielectric.
And the ESP32 touchpad does exactly the same with your finger on the sensing plate !
Here is what Expressif is writing on his "touchpad" sensor :
"A touch sensor system is built on a substrate which carries electrodes and relevant connections under a protective flat surface. When a user touches the surface, the capacitance variation is used to evaluate if the touch was valid".
If we replace the finger by soil it should work !
Expressif API provides a way to measure the number of times the capacitance will charge/discharge when connected to a square wave signal. As the capacitance changes mainly with the soil humidity, this number of charges will also change.
To get better values you should use the "raw measurement" mode of the touchpad sensor.
As said, the touch sensor will count the number of charge/discharge cycles over a fixed period of time (specified by <span class="pre">touch_pad_set_measurement_clock_cycles()</span>
). The count result is the raw data that read from <span class="pre">touch_pad_read_raw_data()</span>
. After finishing one measurement, the touch sensor will sleep until the next measurement start, this interval between two measurements can be set by <span class="pre">touch_pad_set_measurement_interval()</span>
.
And here is the intialization of this API under Arduino IDE:
//soil moisture probes initialization
Serial.println("measuring moisture");
touch_pad_init();
touch_pad_set_voltage(TOUCH_HVOLT_2V7, TOUCH_LVOLT_0V5, TOUCH_HVOLT_ATTEN_1V);
touch_pad_config(TOUCH_PAD_NUM8, 0); //T8
// touch_pad_config(TOUCH_PAD_NUM0, 0); //T0 does not work if coil driver is soldered(will work if not soldered)
// touch_pad_config(TOUCH_PAD_NUM2, 0); //T2 does not work if coil driver is soldered(will work if not soldered)
// touch_pad_config(TOUCH_PAD_NUM3, 0); //T3 does not work if coil driver is soldered(will work if not soldered)
My board exposes 4 touch pads pins but 3 of them are also connected to the motors drivers pins.
So if you solder the two drivers only soilMoisture M1 will work which is T8 on the ESP32.
To read the raw value, it's very simple :
//humidity sensors: read touch output
uint16_t output;
touch_pad_read(TOUCH_PAD_NUM8, &output); //T8 or M1
M1 = float(output);
But does it work ?
For testing purposes I have put the sensor into a small potted plant.
And I have watered it on an almost regular basis.
Results on next log !
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.