How to develop a Soil Moisture Device Using Arduino UNO R3

In this blog, I am going to explain how to develop a soil moisture detecting device using an UNO microcontroller board and a soil moisture sensor. This device can measure real-time soil moisture levels. These devices are mostly used in fields for agriculture farms, construction, cotton spinning industries, etc.... It helps to monitor the real-time moisture level of soil, implement an auto irrigation system in agriculture areas and auto cotton moisture level during the spinning process.
The following prerequisites are required for implementation:
  1. Arduino UNO or Mega
  2. Soil moisture sensor
  3. LCD crystal display [16  X 2 ] 
  4. Breadboard
  5. 10K Potentiometer
  6. 220 Ohm resistor
  7. Connecting wires

Step by step implementation of the soil moisture device

Connection diagram
How To Simply Make A Soil Moisture Device Using Arduino
Step 1
In the first step connect a soil electrode and sensor control unit using the positive and negative terminal. This control unit contains 4 terminals on the bottom side.
(+) --> Positive terminal
 (-) --> Negative terminal
          (AO) --> Analog signal output
        (DO) --> Digital signal output 
Next, make a connection between the sensor control unit and Arduino as above the connection diagram 
                    Sensor control unit                                Arduino
                                (+)  ------------------------------->           5V 
                                 (-)  ------------------------------->           GND
                                 AO -------------------------------->          A0 
Now that the soil moisture sensor has been successfully connected to Arduino, the next step is to connect the LCD crystal to an Arduino UNO Board.
Step 2
Fix the LCD crystal display in the breadboard for easy installation setup. Before installation, refer to the below LCD crystal pin diagram
How To Simply Make A Soil Moisture Device Using Arduino
Place a 10K ohm potentiometer near LCD crystal display. It can adjust the contrast of the LCD screen and create a power connection from Arduino +5V and the GND right and left end of the potentiometer. Make a connection from the center terminal of the potentiometer to VEE (contrast control) LCD crystal display. (Refer to the connection diagram)
Place an 220-ohm resistor in the breadboard and make a connection to (LCD crystal LED +5V Pin)
Step 3
To start a connection with Arduino to LCD crystal display:
      Arduino                              BreadBoard                                     LCD Crystal Display
      Pin 2      --------------------------------------------------------------------------->    Data pin 7
      Pin 3      --------------------------------------------------------------------------->    Data pin 6
      Pin 4      --------------------------------------------------------------------------->    Data pin 5
      Pin 5     ---------------------------------------------------------------------------->    Data pin 4
      Pin 11   ---------------------------------------------------------------------------->    Register select
      Pin 12   ---------------------------------------------------------------------------->    Enable
      + 5V     -----------------> Potentiometer Center Terminal-------->   VEE(Contrast Control)LCD crystal
      +5V      ---------------------------> 220 ohm Resistor -------------------->  LED +5V pin [LCD Crystal]
      GND     -------------------------------------------------------------------------------> Ground pin & LED - Ground pin [Connect to both pin]
All Connections are perfectly done :)
Let's start with the code:
Step 3
In this step, write code for Arduino using the Arduino IDE.
  1. Download Arduino software using this link here.
  2. Install and open an Arduino IDE in your PC/Laptop 
  3. Connect your Arduino board to your computer using a USB data cable 
  4. Copy and paste below the code into the Arduino IDE
  1. #include <LiquidCrystal.h>  
  2. LiquidCrystal lcd(7, 6, 5, 4, 3, 2);  
  4. int sensorPin = A0;  
  5. int sensorValue = 0;  
  6. int percentValue = 0;  
  8. void setup() {  
  9.   Serial.begin(9600);  
  10.   lcd.begin(16, 2);  
  11. }  
  13. void loop() {  
  14. sensorValue = analogRead(sensorPin);  
  15.   Serial.print("\n\nAnalog Value: ");  
  16.   Serial.print(sensorValue);  
  17.    percentValue = map(sensorValue, 1023, 200, 0, 100);  
  18.   Serial.print("\nPercentValue: ");  
  19.   Serial.print(percentValue);  
  20.   Serial.print("%");  
  21.   lcd.setCursor(0, 0);  
  22.   lcd.print("Soil Moisture");  
  23.   lcd.setCursor(0, 1);    
  24.   lcd.print("Percent: ");  
  25.   lcd.print(percentValue);  
  26.   lcd.print("%");  
  27.   delay(1000);  
  28.   lcd.clear();  
  29. }  
Save and upload this sketch to the Arduino microcontroller board.
After the sketch upload is completed, the soil moisture detecting device should start working 


How To Simply Make A Soil Moisture Device Using Arduino
Here is one of the soil moisture detecting devices working perfectly on farmland.