About:
In this tutorial, we are going to interface a Soil Moisture Sensor, FC-28 Hygrometer Module with Surilli Basic M0. This Soil Moisture Sensor measures the volumetric content of water inside the soil and gives us the moisture level as output. The sensor is equipped with both analog and digital output, so it can be used in both analog and digital mode. In this tutorial, we are going to interface the sensor in analog mode.
Soil Moisture Sensor:A typical Soil Moisture Sensor consist of two components. A two legged Lead, that goes into the soil or anywhere else where water content has to be measured. This has two header pins which connect to an FC-28 Hygrometer Module which is in turn connected to the Surilli Basic M0.
The FC-28 Hygrometer Module has a Vin, Gnd, Analog and Digital Data Pins. This means that you can get the values in both Analog and Digital forms. For this tutorial, we will use it in the Analog Form.
Working of Soil Moisture Sensors:Most soil moisture sensors are designed to estimate soil volumetric water content based on the dielectric constant (soil bulk permittivity) of the soil. The dielectric constant can be thought of as the soil's ability to transmit electricity. The dielectric constant of soil increases as the water content of the soil increases. This response is due to the fact that the dielectric constant of water is much larger than the other soil components, including air. Thus, measurement of the dielectric constant gives a predictable estimation of water content.
The soil moisture sensor consists of two probes which are used to measure the volumetric content of water. The two probes allow the current to pass through the soil and then it gets the resistance value to measure the moisture value.
When there is more water, the soil will conduct more electricity which means that there will be less resistance. Therefore, the moisture level will be higher. Dry soil conducts electricity poorly, so when there will be less water, then the soil will conduct less electricity which means that there will be more resistance. Therefore, the moisture level will be lower.
Analog Mode Operation:To connect the sensor in the analog mode, we will need to use the analog output of the FC-28 Hygrometer Module. When taking the analog output from the FC-28 Hygrometer Module, the Soil Moisture Sensor gives us the value from 0-1023. The moisture is measured in percentage, so we will map these values from 0 -100 and then we will show these values on the serial monitor.
You can further set different ranges of the moisture values and turn on or off the water pump according to it.
Hardware Required:- Surilli Basic M0.
- Arduino IDE software.
- Soil Moisture Sensor.
- FC-28 Hygrometer Module.
- Breadboard.
- Connecting Wires.
Connections Between Soil Moisture Sensor, FC-28 Module, and Surilli Basic M0:
+ PIN (FC-28 HYGROMETER MODULE) ---> + PIN (SOIL MOISTURE SENSOR).
- PIN(FC-28 HYGROMETER MODULE) ---> - PIN (SOIL MOISTURE SENSOR).
VCC PIN (FC-28 HYGROMETER MODULE) ---> USB PIN (SURILLI BASIC M0).
A0 PIN (FC-28 HYGROMETER MODULE) ---> A0 PIN (SURILLI BASIC M0).
GND PIN (FC-28 HYGROMETER MODULE) ---> GND PIN (SURILLI BASIC M0).
Set Up Arduino IDE for Surilli:Make sure you have selected the right port, board and processor for the Surilli as shown in the picture below and it is programmable (compile and upload “Blink” from File>Examples>Digital>Blink onto your Surilli to check if everything is working fine).
The Circuitry:The circuitry is very simple. It's mostly the programming. Follow the figure below to set up your hardware.
Now you have completed setting up your hardware and Arduino IDE. Copy and paste the Arduino sketch given below into your Arduino IDE and hit upload. The results can be viewed on the Serial Monitor.
Arduino Code:int sensor_pin = A0;
int output_value;
void setup() {
SerialUSB.begin(9600);
SerialUSB.println("Reading From the Sensor ...");
delay(2000);
}
void loop() {
output_value= analogRead(sensor_pin);
output_value = map(output_value,550,0,0,100);
SerialUSB.print("Moisture : ");
SerialUSB.print(output_value);
SerialUSB.println("%");
delay(1000);
}
Play with the program to see how it reacts to different values and logic.
If you make something fun and interesting, do share it with our community.
That’s all for now. If you have any queries, visit surilli.io or contact our support. Stay connected with the Surilli family for more amazing stuff. :-)
Comments