Indicators and regulators of soil moisture. Corrosion-resistant soil moisture sensor suitable for summer cottages

Connect the Arduino to the FC-28 Soil Moisture Sensor to determine when your soil needs water.

In this article, we are going to use the FC-28 Soil Moisture Sensor with Arduino. This sensor measures the volumetric water content of the soil and gives us the moisture level. The sensor gives us analog and digital data at the output. We're going to connect it in both modes.

The soil moisture sensor consists of two sensors that are used to measure the volumetric water content. Two probes allow the current to pass through the soil, which gives the resistance value, which ultimately allows the moisture value to be measured.

When there is water, the soil will conduct more electricity, which means there will be less resistance. Dry soil does not conduct electricity well, so when there is less water, the soil conducts less electricity, which means there will be more resistance.

The FC-28 sensor can be connected in analog and digital modes. We will first connect it in analog mode and then in digital mode.

Specification

FC-28 Soil Moisture Sensor Specifications:

  • input voltage: 3.3-5V
  • output voltage: 0-4.2V
  • input current: 35mA
  • output signal: analog and digital

Pinout

The FC-28 soil moisture sensor has four contacts:

  • VCC: power
  • A0: analog output
  • D0: digital output
  • GND: ground

The module also contains a potentiometer that will set the threshold value. This threshold value will be compared on the LM393 comparator. The LED will signal us a value above or below the threshold.

Analog mode

To connect the sensor in analog mode, we need to use the analog output of the sensor. The FC-28 Soil Moisture Sensor accepts analog output values ​​from 0 to 1023.

Humidity is measured as a percentage, so we will match these values ​​from 0 to 100 and then display them on the serial monitor. You can set different moisture values ​​and rotate water pump"on / off" according to these values.

Electrical diagram

Connect FC-28 soil moisture sensor to Arduino as follows:

  • VCC FC-28 → 5V Arduino
  • GND FC-28 → GND Arduino
  • A0 FC-28 → A0 Arduino

Code for analog output

For the analog output, we write the following code:

Int sensor_pin = A0; int output_value; void setup () (Serial.begin (9600); Serial.println ("Reading From the Sensor ..."); delay (2000);) void loop () (output_value = analogRead (sensor_pin); output_value = map (output_value , 550,0,0,100); Serial.print ("Mositure:"); Serial.print (output_value); Serial.println ("%"); delay (1000);)

Explanation of the code

First of all, we defined two variables: one for the contact of the soil moisture sensor and the other for storing the sensor output.

Int sensor_pin = A0; int output_value;

In the setup function, the command Serial.begin (9600) will help in communication between Arduino and serial monitor. After that, we will print "Reading From the Sensor ..." on the normal display.

Void setup () (Serial.begin (9600); Serial.println ("Reading From the Sensor ..."); delay (2000);)

In the loop function, we will read the value from the analog output of the sensor and store the value in a variable output_value... Then we will match the output values ​​to 0-100 because moisture is measured as a percentage. When we took readings from dry soil, the sensor value was 550, and in wet soil, the sensor value was 10. We compared these values ​​to get the moisture value. We then printed these values ​​on a serial monitor.

void loop () (output_value = analogRead (sensor_pin); output_value = map (output_value, 550,10,0,100); Serial.print ("Mositure:"); Serial.print (output_value); Serial.println ("%") ; delay (1000);)

Digital mode

To connect the FC-28 soil moisture sensor in digital mode, we will connect the sensor's digital output to the Arduino digital pin.

The sensor module contains a potentiometer, which is used to set the threshold value. The threshold value is then compared to the sensor output value using the LM393 comparator, which is located on the FC-28 sensor module. The LM393 comparator compares the sensor output value and the threshold value, and then gives us the output value via a digital pin.

When the sensor value is greater than the threshold value, the digital output will give us 5V and the sensor LED will light up. V otherwise when the sensor value is less than this threshold value, 0V will be transmitted to the digital output and the LED will not light up.

Electrical diagram

The connections for the FC-28 soil moisture sensor and Arduino in digital mode are as follows:

  • VCC FC-28 → 5V Arduino
  • GND FC-28 → GND Arduino
  • D0 FC-28 → Pin 12 Arduino
  • LED positive → Pin 13 Arduino
  • LED minus → GND Arduino

Code for digital mode

Code for digital mode is below:

Int led_pin = 13; int sensor_pin = 8; void setup () (pinMode (led_pin, OUTPUT); pinMode (sensor_pin, INPUT);) void loop () (if (digitalRead (sensor_pin) == HIGH) (digitalWrite (led_pin, HIGH);) else (digitalWrite (led_pin, LOW); delay (1000);))

Explanation of the code

First of all, we have initialized 2 variables to connect the LED pin and the sensor digital pin.

Int led_pin = 13; int sensor_pin = 8;

In the setup function, we declare the pin of the LED as an output pin, because we will turn on the LED through it. We declared the pin of the sensor as an input pin, because the Arduino will receive values ​​from the sensor through this pin.

Void setup () (pinMode (led_pin, OUTPUT); pinMode (sensor_pin, INPUT);)

In the loop function, we read from the sensor pin. If the value is higher than the threshold, the LED will turn on. If the sensor value is below the threshold value, the indicator will go out.

Void loop () (if (digitalRead (sensor_pin) == HIGH) (digitalWrite (led_pin, HIGH);) else (digitalWrite (led_pin, LOW); delay (1000);))

This concludes the introductory lesson on working with the FC-28 sensor for Arduino. Successful projects to you.

Often on sale you can find such devices that are installed on a flower pot and monitor the level of soil moisture, including, if necessary, a pump and watering the plant. Thanks to such a device, you can safely go on vacation for a week, without fear that your favorite ficus will wither. However, the price of such devices is unreasonably high, because their device is extremely simple. So why buy when you can do it yourself?

Scheme

I propose for assembly a diagram of a simple and proven soil moisture sensor, the diagram of which is shown below:

Two metal rods are lowered into the kidney of the pot, which can be made, for example, by unbending a paper clip. They need to be stuck into the ground at a distance of about 2-3 centimeters from each other. When the soil is dry, it does not conduct well electricity, the resistance between the rods is very high. When the soil is wet, its electrical conductivity increases significantly and the resistance between the rods decreases, this is the phenomenon that underlies the operation of the circuit.
The 10 kΩ resistor and the soil between the rods form a voltage divider, the output of which is connected to the inverting input of the operational amplifier. Those. the voltage on it depends only on how moist the soil is. If the sensor is placed in wet soil, the voltage at the op-amp input will be approximately 2-3 volts. As the earth dries up, this voltage will increase and reach a value of 9-10 volts on completely dry ground (specific voltage values ​​depend on the type of soil). The voltage at the non-inverting input of the op-amp is set manually by a variable resistor (10 kΩ in the diagram, its value can be changed within 10-100 kΩ) in the range from 0 to 12 volts. This variable resistor is used to set the threshold for the sensor. The operational amplifier in this circuit acts as a comparator, i.e. it compares the voltages at the inverting and non-inverting inputs. As soon as the voltage from the inverting input exceeds the voltage from the non-inverting one, a minus supply will appear at the output of the op-amp, the LED will light up and the transistor will open. The transistor, in turn, activates a relay that controls a water pump or an electric valve. Water will begin to flow into the pot, the earth will become wet again, its electrical conductivity will increase, and the circuit will turn off the water supply.
Printed circuit board, proposed for the article, is designed for the use of a dual operational amplifier, for example, TL072, RC4558, NE5532 or other analogs, one of its half is not used. The transistor in the circuit uses low or medium power and PNP structures, you can use, for example, KT814. Its task is to turn the relay on and off, and instead of a relay, you can use a key on a field-effect transistor, as I did. The supply voltage of the circuit is 12 volts.
Download the board:

(Downloads: 371)

Assembling the soil moisture sensor

It may happen that when the soil dries up, the relay does not turn on clearly, but first starts to click quickly, and only after that it is set in the open state. This suggests that the wires from the board to the plant pot are picking up network pickups, which have a detrimental effect on the operation of the circuit. In this case, it does not hurt to replace the wires with shielded ones and put an electrolytic capacitor with a capacity of 4.7 - 10 μF parallel to the soil section, in addition to the 100 nF capacitance indicated in the diagram.
I really liked the work of the circuit, I recommend it for repetition. Photo of the device I assembled:

It will save you from monotonous repetitive work, and a soil moisture sensor will help to avoid excess water - it is not so difficult to assemble such a device with your own hands. The laws of physics come to the rescue of the gardener: moisture in the soil becomes a conductor of electrical impulses, and the more there is, the lower the resistance. As the humidity drops, the resistance increases, and this helps to track the optimal watering time.

The design of the soil moisture sensor consists of two conductors that are connected to a weak source of energy; a resistor must be present in the circuit. As soon as the amount of moisture in the space between the electrodes increases, the resistance decreases and the current increases.

Moisture dries up - resistance increases, current decreases.

Since the electrodes will be in a humid environment, it is recommended to switch them on through a wrench to reduce the damaging effects of corrosion. During normal times, the system is off and only starts up to check the humidity at the push of a button.

Soil moisture sensors of this type can be installed in greenhouses - they provide control over automatic irrigation, so the system can function without human intervention at all. In this case, the system will constantly be in working order, but the condition of the electrodes will have to be monitored so that they do not become unusable under the influence of corrosion. Similar devices can be installed in outdoor beds and lawns - they will instantly get the information you need.

In this case, the system turns out to be much more accurate than a simple tactile sensation. If a person considers the ground to be completely dry, the sensor will show up to 100 units of soil moisture (when evaluated in a decimal system), immediately after watering this value rises to 600-700 units.

After that, the sensor will allow you to monitor the change in moisture content in the soil.

If the sensor is supposed to be used outdoors, it is advisable to carefully seal its upper part in order to prevent information distortion. To do this, it can be coated with a waterproof epoxy resin.

The sensor is assembled as follows:

  • The main part - two electrodes, the diameter of which is 3-4 mm, they are attached to the base made of textolite or other material protected from corrosion.
  • At one end of the electrodes, you need to cut a thread, on the other hand, they are made sharpened for more comfortable immersion into the ground.
  • In the PCB plate, holes are drilled into which the electrodes are screwed; they must be secured with nuts and washers.
  • Outgoing wires must be put under the washers, after which the electrodes are insulated. The length of the electrodes, which will be immersed in the ground, is about 4-10 cm, depending on the container used or the open bed.
  • The sensor requires a 35 mA current source, the system requires a 5V voltage. Depending on the amount of moisture in the soil, the return signal range will be 0-4.2 V. The drag loss will indicate the amount of water in the soil.
  • The soil moisture sensor is connected through 3 wires to the microprocessor; for this purpose, you can purchase, for example, an Arduino. The controller will allow you to connect the system to a buzzer to give a sound signal when the soil moisture is too low, or to an LED, the brightness of the lighting will change when the sensor changes.

Such homemade device can become part of automatic irrigation in the "Smart Home" system, for example, using the MegD-328 Ethernet controller. The web interface shows the moisture level in a 10-bit system: the range from 0 to 300 indicates that the ground is completely dry, 300-700 - there is enough moisture in the soil, more than 700 - the ground is wet, and watering is not required.

The design, consisting of a controller, a relay and a battery, can be removed into any suitable housing, for which any plastic box can be adapted.

At home, using such a humidity sensor will be very simple and reliable at the same time.

The application of the soil moisture sensor can be very diverse. They are most often used in automatic watering systems and manual watering of plants:

  1. They can be installed in flower pots if the plants are sensitive to the water level in the soil. If we are talking about succulents, for example, about cacti, it is necessary to pick up long electrodes that will react to changes in the moisture level directly at the roots. They can also be used on other fragile plants. Connecting to an LED will allow you to pinpoint when it's time to conduct.
  2. They are indispensable for organizing watering of plants. By similar principle air humidity sensors are also assembled, which are needed to start up the plant spraying system. All this will automatically ensure watering of plants and normal level atmospheric humidity.
  3. At the dacha, the use of sensors will allow you not to keep in mind the watering time of each garden bed, the electrical engineering itself will tell you about the amount of water in the soil. This will help prevent over-watering if it has been raining recently.
  4. The use of sensors is very convenient in some other cases as well. For example, they will allow you to control soil moisture in the basement and under the house near the foundation. In the apartment, it can be installed under the sink: if the pipe starts to drip, the automation will immediately report this, and it will be possible to avoid flooding of neighbors and subsequent repairs.
  5. A simple sensor device will allow you to fully equip all problem areas of the house and garden with a warning system in just a few days. If the electrodes are long enough, they can be used to control the water level, for example, in an artificial small reservoir.

Self-fabrication of the sensor will help equip the house automatic system control at minimal cost.

Factory-made components are easy to purchase online or in a specialized store, most of the devices can be assembled from materials that can always be found in the home of an electrical enthusiast.

More information can be found in the video.

Arduino Soil Moisture Sensor designed to determine the moisture content of the ground in which it is immersed. It allows you to find out about insufficient or excess watering your home or garden plants... Connecting this module to the controller allows you to automate the process of watering your plants, vegetable garden or plantation (a kind of "smart watering").

The module consists of two parts: a YL-69 contact probe and a YL-38 sensor, the set includes wires for connection .. A small voltage is created between the two electrodes of the YL-69 probe. If the soil is dry, the resistance is high and the current will be less. If the ground is wet, the resistance is less, the current is slightly more. According to the final analog signal you can judge the degree of humidity. The YL-69 probe is connected to the YL-38 probe by two wires. In addition to the contacts for connecting to the probe, the YL-38 sensor has four contacts for connecting to the controller.

  • Vcc - sensor power supply;
  • GND - ground;
  • A0 - analog value;
  • D0 - digital value of humidity level.
The YL-38 sensor is built on the basis of the LM393 comparator, which supplies voltage to the D0 output according to the principle: wet soil - logic low level, dry soil - logic high level. The level is determined by a threshold value that can be adjusted using a potentiometer. An analog value is supplied to the A0 pin, which can be transmitted to the controller for further processing, analysis and decision making. The YL-38 sensor has two LEDs signaling the presence of a digital signal supplied to the sensor and a digital signal at the D0 output. The presence of a digital output D0 and a level LED D0 allows the module to be used independently, without being connected to the controller.

Module Specifications

  • Supply voltage: 3.3-5 V;
  • Consumption current 35 mA;
  • Output: digital and analog;
  • Module size: 16 × 30 mm;
  • Probe size: 20 × 60 mm;
  • Total weight: 7.5 g.

Usage example

Let's consider connecting a soil moisture sensor to an Arduino. Let's create a project of the soil moisture level indicator for indoor plant(your favorite flower that you sometimes forget to water). We will use 8 LEDs to indicate the soil moisture level. For the project we need the following details:
  • Pay Arduino Uno
  • Soil moisture sensor
  • 8 LEDs
  • Bread board
  • Connecting wires.
Let's put together the circuit shown in the figure below.


Let's launch the Arduino IDE. Let's create a new sketch and add the following lines to it: // Soil moisture sensor // http: // site // contact for connecting the analog output of the sensor int aPin = A0; // pins for connecting indication LEDs int ledPins = (4,5,6,7,8,9,10,11); // variable for storing the sensor value int avalue = 0; // variable of the number of lighted LEDs int countled = 8; // full watering value int minvalue = 220; // value of critical dryness int maxvalue = 600; void setup () (// initialization of the serial port Serial.begin (9600); // setting the LED indication pins // to OUTPUT mode for (int i = 0; i<8;i++) { pinMode(ledPins[i],OUTPUT); } } void loop() { // получение значения с аналогового вывода датчика avalue=analogRead(aPin); // вывод значения в монитор последовательного порта Arduino Serial.print("avalue="); Serial.println (avalue); // scale the value by 8 LEDs countled = map (avalue, maxvalue, minvalue, 0.7); // indication of the humidity level for (int i = 0; i <8; i ++) (if (i <= countled) digitalWrite (ledPins [i], HIGH); // light up the LED else digitalWrite (ledPins [i], LOW) ; // turn off the LED) // pause before the next value is received 1000 ms delay (1000); ) The analog output of the sensor is connected to the analog input of the Arduino, which is an analog-to-digital converter (ADC) with a resolution of 10 bits, which allows the output to receive values ​​from 0 to 1023. The value of the variables for full irrigation (minvalue) and strong dry soil (maxvalue ) we get experimentally. Greater dryness of the soil corresponds to a greater value of the analog signal. Using the map function, we scale the analog value of the sensor to the value of our LED indicator. The higher the soil moisture, the higher the value of the LED indicator (the number of LEDs lit). Having connected this indicator to a flower, we can see the degree of humidity on the indicator from a distance and, when we determine the need for watering.

(! LANG: Frequently Asked Questions FAQ

1. Power LED is off
  • Check the presence and polarity of the power supplied to the YL-38 sensor (3.3 - 5 V).
2. When watering the soil, the soil moisture indication LED does not light up
  • Adjust the response threshold with the potentiometer. Check the connection of the YL-38 probe to the YL-69 probe.
3. When watering the soil, the value of the analog output signal does not change
  • Check the connection of the YL-38 probe to the YL-69 probe.
  • Check for a dipstick in the ground.

The poet Andrei Voznesensky once said: "laziness is the engine of progress." Perhaps, it is difficult to disagree with this phrase, because most electronic devices are created precisely for the purpose of making our everyday life easier with you, full of worries and all sorts of vain affairs.

If you are reading this article now, then you are probably very tired of the process of watering flowers. After all, flowers are delicate creatures, if you pour them over, you are unhappy, you forget to water for a day, that's it, they are about to fade. And how many flowers in the world died just from the fact that their owners went on vacation for a week, leaving the poor green fellows to wither in a dry pot! Scary to imagine.

It is to prevent such terrible situations that automatic irrigation systems are invented. A sensor is installed on the pot that measures soil moisture - it is for stainless steel metal bars, stuck into the ground at a distance of a centimeter from each other.

They are connected via wires to a circuit whose task is to open the relay only when the humidity drops below the set one and close the relay at the moment when the soil is again saturated with moisture. The relay, in turn, controls a pump that pumps water from the reservoir directly under the root of the plant.

Sensor circuit

As you know, the electrical conductivity of dry and wet soil differs quite significantly, it is this fact that underlies the operation of the sensor. The 10 kΩ resistor and the soil section between the bars form a voltage divider, their midpoint is connected directly to the input of the op-amp. The voltage is supplied to the other input of the op-amp from the midpoint of the variable resistor, i.e. it can be adjusted from zero to supply voltage. With its help, the switching threshold of the comparator is set, in the role of which the op-amp works. As soon as the voltage at one of its inputs exceeds the voltage at the other, the output will be a logical "1", the LED will light up, the transistor will open and turn on the relay. Any transistor can be used, PNP structure, suitable for current and voltage, for example, KT3107 or KT814. Operational amplifier TL072 or any similar, for example, RC4558. A low-power diode should be installed in parallel with the relay winding, for example, 1n4148. The supply voltage of the circuit is 12 volts.

Due to the long wires from the pot to the board itself, a situation may arise that the relay does not switch clearly, but begins to click with the frequency of the alternating current in the network, and only after a while it is set in the open position. To eliminate this bad phenomenon, an electrolytic capacitor with a capacity of 10-100 μF should be installed in parallel with the sensor. Archive with the board. Happy assembly! Author - Dmitry S.

Discuss the article SCHEME OF SOIL MOISTURE SENSOR