HUM: SOIL HUMIDITY SENSOR
You are a beginner with Dasduino. Or electronics? A specific module caught your eye, but you do not know how to use it? Do not worry, HUM is here for you! How to Use Module (HUM) is a blog tutorials series by soldered where you will find all you need in order to begin working with your favorite module. Tutorials include: technical characteristics, work principle, instructions on how to connect the module with Dasduino and the basic code. Everything else is left to your imagination.
In today’s tutorial, we will see how the soil humidity sensor works, how and when we can use this sensor along with its advantages and disadvantages.
For example, they can be used in automated plant watering projects, thereby reducing human labor and time spent doing simple plant care tasks.
• Voltage : 3V – 5V
• Output: digital and analog
• Dimensions : 40mm x 20mm
• LM393 comparator on the board
• Manufactured by soldered in Croatia
HOW DOES IT WORK?
This type of soil humidity sensor can be perceived as a variable resistor that changes values with the change in soil conductivity between its conductors. When the sensor’s conductor (fork) is in the air, or when there is no medium that can conduct electricity, the Dasduino will read it as a value of about 1000, ie. near the upper boundary of the A/D converter. When the sensor’s conductors are completely immersed in the water, Dasduino will display values around 300-400. Therefore, the sensor works on the principle of measuring the conductivity of the soil in which its conductors (fork) are located, the damper the soil, the higher the conductivity of the soil.
There is a built-in comparator on the module, which provides HIGH / LOW (0V or 5V) values on the “DO” pin, depending on the threshold that is set by rotating the potentiometer on the module, and on the “AO” pin, it provides values between 0V and 5V which can be read as values between 0 and 1023 by the Dasduino using its ADC converter, depending on the humidity of the soil.
One of the main issues of such sensors is their relatively short lifecycle, due to constant exposure to external conditions, especially to humidity. Due to the flow of DC current, the sensor will slowly lose its copper layer and will eventually no longer be able to conduct electricity or measure humidity of the soil. But, there is a simple solution that can significantly extend the lifecycle of the sensor. Instead of connecting the +5V pin directly to +5V, we can connect that pin to some other Dasduino digital pin and therefore control the current flowing through the sensor. In the first case, the current will flow constantly through the sensor and it will corrode faster, while in the second case, the current will flow only when we need to make a measurement, and we can do it, e.g. every half-hour.
HOW TO CONNECT IT?
In the following example, we will use a pin on the analog sensor that will provide values between 0 and 1023 depending on the humidity of the soil. Connect GND to Dasduino’s GND, + 5V to the digital pin 10 and connect the analog output of the sensor to the A0 pin on the Dasduino. Finally, we just need to connect the “fork” to the bottom two pins of the module according to the image below.
#define VccPin 10
//start the communication with the computer
//turn the sensor off
//turn the sensor on
//read the sensor's value
//turn the sensor off
//convert the reading to percentage
(ocitanje, 400, 1002, 100, 0);
(ocitanje, 0, 100);
//display the percentage of soil humidity on the Serial Monitor
"Postotak vlage = "
//wait 5 seconds