Overview of Soil Moisture
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 to the topic Soil Moisture Sensor in the sensors and modules section.
Connection Diagram of Soil Moisture with MSP-EXP430G2 TI Launchpad
Measure Soil Moisture using MSP-EXP430G2 TI Launchpad
Measuring soil moisture in terms of percentage.
Here, the analog output of the 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 values from 0 to 1023.
This can be represented as moisture value in terms of percentage using the formula given below.
Moisture in percentage = 100 – (Analog output * 100)
For zero moisture, we get the maximum value of 10-bit ADC, i.e. 1023. This, in turn, gives 0% moisture.
Tread Carefully: MSP-EXP430G2 TI Launchpad board has a RAM of 512 bytes which is easily filled, especially while using different libraries. There are times when you need the Serial buffer to be large enough to contain the data you want and you will have to modify the buffer size for the Serial library. While doing such things, we must ensure that the code does not utilize more than 70% RAM. This could lead to the code working in an erratic manner, working well at times, and failing miserably at others.
There are times when the RAM usage may exceed 70% and the codes will work absolutely fine, and times when the code will not work even when the RAM usage is 65%.
In such cases, a bit of trial and error with the buffer size and/or variables may be necessary.
Soil Moisture Measurement Code for MSP-EXP430G2 TI Launchpad
const int sensor_pin = A3; /* Soil moisture sensor O/P pin */
void setup() {
Serial.begin(9600); /* Define baud rate for serial communication */
}
void loop() {
float moisture_percentage;
int sensor_analog;
sensor_analog = analogRead(sensor_pin);
moisture_percentage = ( 100 - ( (sensor_analog/1023.00) * 100 ) );
Serial.print("Moisture Percentage = ");
Serial.print(moisture_percentage);
Serial.print("%\n\n");
delay(1000);
}
Video of Soil Moisture Measurement using MSP-EXP430G2 TI Launchpad
Components Used |
||
---|---|---|
TI Launchpad MSP-EXP430G2 TI Launchpad MSP-EXP430G2 |
X 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. |
X 1 |
Downloads |
||
---|---|---|
|
Soil_Moisture_Sensor_Interfacing_With_TI_Launchpad_INO | Download |