This sensor (Moisture sensor Seeds) is useful for measuring the moisture present in the soil. For example it can be used in gardening, placing it in the ground near the plant. This way you will know if the soil needs to be watered.
A useful sensor for irrigation systems
The beauty of working with boards like Arduino is that they are inexpensive, simple to use and allow the use of a myriad of different sensors. These allow us to create infinite applications, such as the construction of an automatic irrigation system. There are sensors, such as the Moisture Sensor (humidity detector), which once inserted into the ground allow you to monitor the degree of humidity. When the ground is too dry, we can program the Arduino board to open an irrigation system for a certain time, and for that specific terrain. Thus creating an automatic irrigation system
Moisture Sensor – technical characteristics
Let’s see in detail the Moisture Sensor distributed by Seeeds.
- Size: 2.0 x 6.0 cm
- Voltage 3.3-5V
- Current: 0 – 35 mA
- Output values :
- 0 – 300 dry soil
- 300 – 700 moist soil
- 700 – 950 wet soil
Connecting with Arduino
Icolors of the outgoing cables:
Red | 5V |
Black | GND |
White | Not connected |
Yellow | Signal A0 |
Programming Arduino to work with the Moisture Sensor
Now let’s see a very simple example sketch to program on Arduino in order to interrogate the sensor and thus see a reading number value.
int sensorPin = A0;
int sensorValue = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
sensorValue = analogRead(sensorPin);
Serial.print("Moisture = ");
Serial.print(sensorValue);
delay(1000)
}
By compiling the sketch and then running it, if we open the Serial Monitor we will have a continuous series of readings (about 1 second from each other) in which a numerical value between 0 and 950 will be shown. This value corresponds to the humidity level detected in the ground. Low values will describe a dry soil, devoid of water, while at gradually higher values, we will have an increasingly humid soil. To create a reference range.
0-300 | Dry soil |
301-600 | Moist soil |
601-650 | Wet soil |