Ever got tired of Gardening? Or ever wondered “Couldn’t this be easier?” Well, worry not strangers, for a simple sensor is a key to making things even easier. In this tutorial, we will use an FC-28 Soil Hygrometer Sensor or a moisture sensor. This sensor measures the volumetric content of water in the soil and produces an analog signal based on it. We will use these signals to measure the percentage of water in the soil. If this percentage drops below a certain value, Arduino will set off a buzzer, therefore reminding us to water the plants.
Visit my other projects at my home page, here.
OVERVIEW
FC-28 is a sensor that has two probes which are inserted into the soil.
The more the content of water in the soil, the lesser will be the resistivity and the more will be the conductivity between the two probes. If the water content is less in the soil, the resistance will be greater and the conductivity will drop. The sensor gives us an analog value based on conductivity.
Most of the time, the sensors come with a amplifier that help us to interface it to a micro-controller.
But the sensor is not without problems. Continued use of this sensors results in corrosion of the probes. A simple way to increase the life of the moisture sensor is to only take readings after intervals. Therefore, in the codes below, we will take readings from the hygrometer sensor after an interval of 1 minute.
PINOUT
- Vcc: 3.3V to 5V
- GND: Ground pin
- DO: Digital Output (0 or 1)
- AO: Analog output
The analog output of the sensor varies from 0 (in air) to 1023 (in water). Therefore, we will map the analog output in the range of 0 to 100 so that we can easily define functions based on a small range.
CODE (Analog Mode)
I had a plant that was native to the Indian Subcontinent and it required constant moisture of 40%. If you have a plant with some other moisture requirements, then you ought to change the ‘if’ statement and replace the <= value with the value you need.
CODE (Digital Mode)
When we connect the sensor in digital Mode, i.e. when we take reading using the D/O pin, the pin gives a HIGH output when the value read by the sensor is greater than the threshold value. Else, it gives a LOW output when the value is lower than the threshold value.
The threshold value is set by a potentiometer atop the amplifier. Rotate the potentiometer to change the threshold value.
With this code, the buzzer will buzz only when the value read by the potentiometer is less than the threshold value.
You can download Arduino IDE here for easy uploading and verification of sketches.
Please do visit my other projects, by clicking here.
Please follow and like us:
Tags:Arduino
Comments