Project Overview:

In this project, you'll learn how to use an Arduino to monitor soil moisture levels and display the readings on an LCD. By integrating a soil moisture sensor with an LCD display, you'll be able to visually track the moisture level of the soil, which is useful for gardening and plant care.

How It Works:

The Arduino reads the analog value from a soil moisture sensor connected to an analog pin. It then converts this value into a moisture percentage and displays it on a 16x2 LCD screen. This project demonstrates how to use an analog sensor with an LCD for real-time monitoring.

Components List:

  1. Arduino Board (e.g., Uno, Nano, etc.)
  2. Soil Moisture Sensor (e.g., LM35 or similar analog sensor)
  3. 16x2 LCD Display
  4. Jumper Wires
  5. Breadboard (optional)
  6. Power Supply (for Arduino)

Software List:

  • Arduino IDE (Integrated Development Environment)

Circuit Diagram and Connection:


Component

Arduino Pin

Soil Moisture Sensor

Analog Pin A0

LCD Display (RS)

Digital Pin 2

LCD Display (E)

Digital Pin 3

LCD Display (D4)

Digital Pin 4

LCD Display (D5)

Digital Pin 5

LCD Display (D6)

Digital Pin 6

LCD Display (D7)

Digital Pin 7

LCD Display (VCC)

5V

LCD Display (GND)

GND

  1. Connect the VCC pin of the LCD to the 5V pin on the Arduino.

  2. Connect the GND pin of the LCD to the GND pin on the Arduino.

  3. Connect the RS, E, D4, D5, D6, and D7 pins of the LCD to digital pins 2, 3, 4, 5, 6, and 7 on the Arduino, respectively.

  4. Connect the output of the soil moisture sensor to Analog Pin A0 on the Arduino.

  5. Connect the VCC and GND pins of the soil moisture sensor to the 5V and GND pins on the Arduino.

Project Code:

#include <LiquidCrystal.h>


// Initialize the LCD with the numbers of the interface pins

LiquidCrystal lcd(2, 3, 4, 5, 6, 7);


void setup() {

  const int LM35 = A0;  // Define the analog pin connected to the soil moisture sensor

  lcd.begin(16, 2);     // Initialize the LCD with 16 columns and 2 rows

  lcd.print("SoilM = "); // Print a label to the LCD

}


void loop() {

  const int LM35 = A0;  // Define the analog pin connected to the soil moisture sensor

  int value = analogRead(LM35);              // Read the analog value from the sensor

  float Moisture = value * 500.0 / 1023.0;  // Convert the value to moisture percentage

  lcd.setCursor(6, 0);                       // Set cursor to column 6, row 0

  lcd.print(Moisture);                      // Print the moisture percentage

  lcd.setCursor(11, 1);                     // Set cursor to column 11, row 1

}


Explanation of the Code:

  • Library Initialization: #include <LiquidCrystal.h> imports the LCD library.

  • LCD Initialization: LiquidCrystal lcd(2, 3, 4, 5, 6, 7); sets up the LCD with the specified pins.

  • Setup Function:

    • lcd.begin(16, 2); initializes the LCD with a 16x2 display.

    • lcd.print("SoilM = "); prints a label on the first row of the LCD.

  • Loop Function:

    • int value = analogRead(LM35); reads the analog value from the sensor.

    • float Moisture = value * 500.0 / 1023.0; converts the sensor value to a percentage.

    • lcd.setCursor(6, 0); positions the cursor to the appropriate location on the LCD.

    • lcd.print(Moisture); displays the moisture percentage.

Test and Troubleshooting:

  1. Testing: Upload the code to your Arduino and observe the LCD display. The moisture percentage should update in real-time based on the soil moisture sensor’s readings.

  2. Troubleshooting:

    • Ensure all connections are secure and correctly made.

    • Verify that the LCD display is powered and connected properly.

    • Check the sensor’s calibration if the moisture readings seem incorrect.

Summary:

In this project, you successfully integrated a soil moisture sensor with an Arduino and an LCD display to monitor soil conditions. This project introduces key concepts in sensor data reading and display, providing a foundation for more advanced environmental monitoring systems.


No comments

Theme images by Dizzo. Powered by Blogger.