Description
The Soil Moisture Sensor Module with Probes determines the amount of soil moisture by measuring the resistance between two metallic probes that is inserted into the soil to be monitored. This can be used in an automatic plant watering system or to signal an alert of some type when a plant needs watering.
PACKAGE INCLUDES:
- Soil Moisture Sensor Module
- Soil probes with 2-wire interface cable, 120cm long
- 1×4 right angle header
KEY FEATURES OF SOIL MOISTURE SENSOR MODULE:
- Analog output of moisture content
- Digital output of moisture content with adjustable set-point
- Remote mounted electronics with 120cm (47″) cable
- 3.3 or 5V operation. Low power so may be driven from digital pin on MCU
These sensors work by measuring the resistance between the two metallic probes that are inserted into the soil. That resistance will depend mostly on the moisture content of the soil. The resistance affects a voltage divider and so an analog voltage output is available which can be read by an analog input on a MCU that roughly corresponds to the moisture content of the soil.
The more moisture in the soil, the lower the resistance. A lower resistance gives a lower analog voltage reading. As the soil dries out, the resistance increases. The higher the resistance (drier the soil), the higher the voltage will be.
Besides the analog output, there is also a LM393 comparator IC that provides a LOW output when that analog voltage goes below a certain level as moisture increases. An green LED lights when this output goes LOW. A potentiometer on the module allows the set-point of this digital output to be adjusted. This output can be monitored by a digital input pin on an MCU, or can be used to drive a relay to activate a small water pump to water the plant without necessarily having a MCU in the loop. A red LED indicates power is applied.
Besides moisture, there are other factors that can affect the resistance including minerals that are dissolved in the water which can come from fertilizers and other sources. The full length of the probes should be inserted into the soil if possible. There is plastic sleeving on the upper parts of the probes to help waterproof the electrical connections. The depth that the forks are inserted will affect the readings and therefore should be kept reasonably constant.
Module Connections
On the electronics module there are 2 connectors.
1×4 Header Connector
- VCC = 5V or 3.3V. Should match the voltage of an attached MCU.
- GND = Ground, must be common with the MCU.
- D0 = Digital Output of comparator circuit. May be connected to MCU or directly to a logic 5V controlled relay or similar device.
- A0 = Analog Output usually connected to an analog input on a MCU.
1×2 Sensor Connector
- Connects the probe cable to the electronics module. The connector is keyed, though polarity does not matter.
OUR EVALUATION RESULTS:
It is not possible to directly define an actual percentage of moisture in the soil from the measurements taken, but it is fairly straightforward to define basic ranges for what would be considered ‘too dry’, ‘too wet’ and ‘about right’.
To do that, measure the soil under 3 basic conditions:
- When dry enough so that the plant should be watered
- When watered so it has the desired amount of moisture that would be ideal for the plant
- When watered so the soil is too wet and not ideal for the plant.
From those 3 measurements, ranges for each of the 3 conditions can be initially determined and then honed in on once the setup goes into operation.
On most MCUs like Arduino, the ADC is 10-bit, so the measurement has a range of 0-1023. When the sensor is dry in open air, the ADC will read close to the upper limit of 1023. In my own test, that reading was 985-1000. When the sensor was inserted into a cup of clean water, the reading dropped to about 175.
With our test plant, we got the following readings:
- Dry enough that the plant should have already been watered was up around 850 – 950
- Just right was in the 300 – 750 range
- Too wet (just watered) was down in the 250-300 range
Based on that data, the program below defines the following ranges:
- < 300 is too wet
- 301-750 is the target range
- > 750 is dry enough that we should water the poor thing.
The program reports the digital output status as well as the analog but doesn’t do anything with it. The digital trip point can be set with the pot.
The probes are made from a modest grade of stainless steel and corrosion will take its toll on the sensor probes over time. An occasional rub down with fine sandpaper or scotch brite pade will help to remove any corrosion build-up.
Having power applied to the probe electrodes speeds the rate of corrosion significantly, so to minimize that issue the device can be powered off of a pin on the MCU so that it can be turned on only when a measurement is being taken. Total power draw with both LEDs lit is only about 3mA so that is easily within the drive capability of a MCU Since soil doesn’t dry out very quickly, readings can be spaced relatively far apart depending on your environment, perhaps just once or twice a day.
It does take some time for the readings to stabilize after power is applied. If controlling power with a digital pin on the MCU, the pin should be driven to a logic HIGH to power the device and then wait perhaps 5 minutes before taking a reading and then shutting power back off by driving the pin to a logic LOW.
The program below powers the device off the MCU power on the microcontroller and takes a measurement every second for test purposes. It takes the analog and digital measurement separately mainly for illustrative purposes.
The program is using pin A0 for the analog reading but this can be any analog pin. Similarly pin 8 is doing the digital reading but these can be changed to any analog and digital pins as needed.
/* Soil Moisture Sensor Module Test Monitor soil moisture analog output 'A0' on ADC input A0 Monitor soil moisture digital output 'D0' on digital input pin 8. */ // Define pins used below #define ADC_PIN A0 // Use any available ADC Pin, connect to A0 sensor pin #define DIGITAL_PIN 8 // Use any available digital pin, connect to D0 sensor pin #define SOIL_WET 300 // Define max value we consider soil 'wet' #define SOIL_DRY 750 // Define min value we consider soil 'dry' //=============================================================================== // Initialization //=============================================================================== void setup() { Serial.begin(9600); // Set Serial Monitor window comm speed } //=============================================================================== // Main //=============================================================================== void loop() { int returnedADCData = readSoilADC(); // Read sensor analog output Serial.print("Analog Output = "); Serial.print(returnedADCData); // Print raw ADC data Serial.print("\tDigital Output = "); Serial.print(readSoilDigital()); // Read sensor digital output and print directly if (returnedADCData < SOIL_WET) { // Determine status of our soil moisture situation Serial.println("\tConclusion: Soil is too wet"); } else if (returnedADCData >= SOIL_WET && returnedADCData < SOIL_DRY) { Serial.println("\tConclusion: Soil moisture is perfect"); } else { Serial.println("\tConclusion: Soil is too dry - time to water!"); } delay(1000); // Take a reading every second for test purposes. // Normally we would take reading perhaps every 12 hours } //=============================================================================== // Function readSoilADC returns the analog soil moisture measurement //=============================================================================== int readSoilADC() { int val_ADC = analogRead(ADC_PIN); // Read analog value from sensor return val_ADC; // Return analog moisture value } //=============================================================================== // Function readSoilDigital returns the digital soil moisture value //=============================================================================== int readSoilDigital() { int val_Digital = digitalRead(DIGITAL_PIN); //Read the digital value from sensor return val_Digital; // Return digital moisture value }
BEFORE THEY ARE SHIPPED, THESE MODULES ARE:
- Sample tested per incoming shipment
Notes:
- None
Technical Specifications
Operating Ratings | ||
Vcc | Range | 3.3 to 5V |
I(typ) | With both LEDs lit | < 8mA |
Vout | Analog Output | 2V to 5V (typ) |
Dimensions | ||
Sensor Probes | metal probes | 88mm (3.5″) |
Sensor Electronics Board | L x W (PCB) | 30 x 15mm (1.2 x 0.6″) |
Cable | Length | 120cm (47″) |