Product Introduction #
Soil moisture sensor is a sensor used to detect soil moisture, which can sense the soil condition in time to make plants grow better.
The soil moisture sensor is to insert two probes into the soil, and then as the current passes through the soil, the sensor obtains the resistance value by reading the current change between the two probes, and converts this resistance value to the moisture content. The higher the moisture (and the less resistance), the better the conductivity of the soil. Therefore, if the soil is short of water, the analog value output by the sensor will decrease; Otherwise, it will increase.
Application reference: smart agriculture, plant research and other scenarios that need to sense soil moisture.
Parameter Specification #
Parameters | Value/Description |
Operating voltage | 3.3V~5V |
output voltage | 0V~2.3V |
Output signal | Analog signal |
Size | 2.3cm*6.28cm |
Wiring Diagram #
Note: Expansion board is attached to esp32 controller board.
Moisture Sensor | ESP32 |
VCC | 5V |
GND | GND |
Sign | Pin 32 |
Sample Code #
void setup() {
pinMode(32,INPUT);//Set pin 32 to input mode
Serial.begin(115200);//Set baud rate to 115200
}
void loop() {
Serial.println(analogRead(32));//Read the state of pin 32 and print it to the serial monitor
delay(1000);
}
Note: If you are using an Arduino board, then change the pin in the program to PIN A0, set the baud rate to 9600, and then connect the hardware pin to PIN A0 and upload the program.
Test Result #
After uploading the code to the controller board, open the serial port monitor of the Arduino IDE and set the baud rate to 115200.
When we place the module in wet soil or water, the wetter the module’s contact surface, the larger the value returned; When we place the module into dry soil or air, the drier the contact surface of the module, the smaller the value returned.
Note: The live part of the sensor should not touch water.