ElectroPeak
Published © CC BY-SA

Complete Guide to Use Soil Moisture Sensor w/ Examples

In this tutorial, you will learn how to use a soil moisture sensor. Practical examples are also provided to help you master the code.

BeginnerProtip1 hour173,781
Complete Guide to Use Soil Moisture Sensor w/ Examples

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Soil Moisture Sensor
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

code

Arduino
/* 
  Soil Moisture Sensor  
  modified on 21 Feb 2019 
  by Saeed Hosseini @ Electropeak 
  https://electropeak.com/learn/ 
*/
#define SensorPin A0 
 float sensorValue = 0; 
void setup() { 
  Serial.begin(9600); 
} 
void loop() { 
  for (int i = 0; i <= 100; i++) 
  { 
    sensorValue = sensorValue + analogRead(SensorPin); 
    delay(1); 
  } 
  sensorValue = sensorValue/100.0; 
  Serial.println(sensorValue); 
  delay(30); 

}

Credits

ElectroPeak

ElectroPeak

57 projects • 736 followers
At ElectroPeak we want to teach you to enjoy electronics more. We offer Top-notch guides and worry-free shopping experience.

Comments