Soil Moisture Sensor Interfacing with ARM MBED

Overview of Soil Moisture

Soil Moisture Sensor

 

  • Soil moisture is basically the content of water present in the soil. This can be measured using a soil moisture sensor which consists of two conducting probes that act as a probe.
  • It can measure the moisture content in the soil based on the change in resistance between the two conducting plates.
  • The resistance between the two conducting plates varies in an inverse manner with the amount of moisture present in the soil.

For more information about soil moisture sensor and how to use it, refer the topic Soil Moisture Sensor in the sensors and modules section.

 

Connection Diagram of Soil Moisture with ARM MBED (LPC1768)

Interfacing Soil Moisture Sensor With ARM MBED

 

Measure Soil Moisture using LPC1768 ATM MBED

Measuring soil moisture in terms of percentage.

 

Here, the analog output of soil moisture sensor is processed using ADC. The moisture content in terms of percentage is displayed on the serial monitor.

The output of the soil moisture sensor changes in the range of ADC value from 0 to 4095.

This can be represented as moisture value in terms of percentage using formula given below.

Analog output = ADC value

Moisture in percentage = 100 – (Analog output * 100)

For zero moisture, we get a maximum value of 12-bit ADC, i.e. 4095. This in turn gives 0% moisture.

 

Soil Moisture Code for LPC1768 ARM MBED

#include "mbed.h"

AnalogIn soil_moisture(p15);

int main() {
    float value = 0;
    while(1) {
        value = (100-((soil_moisture)*100));
        printf("Soil Moisture = %f\n\r", value);
        wait(0.5);
    }
}

Components Used

ARM mbed 1768 LPC1768 Board
ARM mbed 1768 Board
1
Soil Moisture Sensor
Soil moisture sensor is used to measure the water content (moisture) in soil. It is used in agriculture applications, irrigation and gardening systems, etc.
1

Downloads

Soil_Moisture_uvision5_lpc1768 Download
Ad