विभाग : FABLAB -Practice Work : Moisture sensor

I have practiced and learnt connectivity of moisture sensor with using LCD display.  After the connection, I tested the sensor in water and mud and took readings on serial monitor in arduino software.  I have realized connectivity of sensor and LCD and I have realized this sensor is very useful.

  • Connections :

  • Readings :



  • Programming Code

#include <LiquidCrystal.h>

int SensorPin = A0;
int SensorValue = 0 ;
int soil;

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  pinMode(SensorPin, INPUT);
  
  lcd.begin(16, 2);

  lcd.clear();
  
  Serial.begin(9600);
  Serial.print("soil moisture sensor");
  }

void loop() {
  
   SensorValue = analogRead(SensorPin); 
   SensorValue = constrain(SensorValue, 485, 1023);//compare Max and Min Value
   soil=map(SensorValue, 485, 1023, 0,100);// Convert Analog Value into Percentage Form
   
   Serial.print(100-soil);
   Serial.println("%");
   lcd.setCursor(0,0);
   
   lcd.print("Moisture Sensor Value:");
   lcd.setCursor(0,1);
 
   lcd.print(100-soil);
   lcd.print("%");  
  
    
 
}






Post a Comment