Arduino Lesson 17: Soil Moisture Sensor
Arduino Lesson 17

Soil Moisture Sensor

Measure soil moisture

Components Required



Soil moisture sensors typically refer to sensors that estimate volumetric water content. Another class of sensors measures another property of moisture in soils called water potential; these sensors are usually referred to as soil water potential sensors and include tensiometers and gypsum blocks.

Learning outcomes:

  • Using Soil moisture sensors and implement its applications
  • Working principle of soil moisture sensor


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.


Connect the soil-moisture sensor to the Magicbit. As usually in here also, we connect the sensor module to the upper left (D32) connector on the Magicbit. After connecting the sensor module, put it into a wet soil mixture forget results. Then connect the Magicbit to your pc and upload the code below.



int SENSOR = 32;
int output_value ;

void setup() {
   Serial.println("Reading From the Sensor ...");


void loop() {

   output_value= analogRead(SENSOR);
   output_value = map(output_value,550,0,0,100);
   Serial.print("Mositure : ");


‘Output_value = map(output_value, 550,0, 0,100)’ — output_value is a user-defined variable. To display a moisture percentage we should map the analog output value of the sensor given according to the sample (the wet soil mixture). From the serial monitor, we can get our outputs.

Related Posts
Leave a Reply