Menu Close

Soil Moisture Sensor on Arduino

Robo India presents tutorial on how to read soil moisture data through Analog Soil Moisture sensor on Arduino platform.

1. Introduction:

This tutorial explains how to read soil moisture data using Analog Soil Moisture Sensor on Arduino Platform.

Robo India offers Soil moisture sensor that gives analog signal. So here in this tutorial we are reading data from Analog Moisture Sensor, so we will get reading in the range 0 to 1023. Lesser the value means lesser the moisture in soil.

2. Circuit

Make following connections of Analog Soil Moisture Sensor to Arduino in the following manner.

3. Programming

You may download following code from here.

/*
  Soil Moisture Sensor example
  www.roboindia.com
 
 The soil moisture sensor offered by Robo India gives signal in analog.
 This code reads analog signal from soil moisture sensor and gives prints 
 sensor value on serial monitor. 
 
 The circuit:
 * The soil moisture sensor signal pin is connected to A0.
 * Connect VCC(sensor) to 5V(sensor) and GND to GND
 */

const int soil_sensor = A0;  // Analog input pin that the soil moisture sensor is attached to
int sensorValue = 0;         // store sensor input value


void setup() {
  // initialize serial communications at 9600 bps:
  Serial.begin(9600); 
}

void loop() {
  // read the sensor:
  sensorValue = analogRead(soil_sensor);            
  
  // print the sensor results to the serial monitor:
  Serial.print("Moisture Value = " );                       
  Serial.println(sensorValue);      

  // delay of one second
  delay(1000);                     
}

6. Output

Run the following code and you will get the following output.

This is how to use analog soil mositure sensors on Arduino.

If you have any query please write us at support@roboindia.com

Thanks and Regards
Content Development Team 
Robo India
http://roboindia.com

Leave a Reply