Soil Moisture Sensor

Image.png
Image.jpg
Image.png
COMPONENTS:
-Arduino Uno
-Soil Moisture Sensor
-LCD I2C

CODE:
//I2C LCD:
#include <Wire.h> // Comes with Arduino IDE
#include <LiquidCrystal_I2C.h>
// Set the LCD I2C address
LiquidCrystal_I2C lcd(0x27, 20, 4);
// These constants won’t change. They’re used to give names
// to the pins used:
const int analogInPin = A0; // Analog input pin that the Sensor is attached to
int sensorValue = 0; // value read from the Soil Moisture
void setup() {
  lcd.init();
  lcd.backlight();
  delay(100);
}
void loop() {
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print(“Soil Moisture:”);// print the results to the LCD Display:
  sensorValue = analogRead(analogInPin);// read the analog in value:
  lcd.setCursor(0, 1);
  lcd.print(sensorValue);
  // wait 300 milliseconds before the next loop for the
  //analog-to-digital converter to settle after the last reading:
  delay(300);
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s