In this article, you will see how to connect and interface soil moisture sensor with Arduino step by step. Before getting started you must know how the sensor works.
Contents
Working of Soil Moisture Sensor
Soil moisture sensor uses an electrical parameter called capacitance to measure the dielectric permittivity. This dielectric permittivity is a function of water content in the soil. Soil moisture sensor creates some potential proportional to the dielectric permittivity which is proportional to the moisture content in the soil.
Step 1: Components Required
Arduino Uno
Soil Moisture Sensor
Jumper Wires
Step 2 : Watch Video Tutorial
Step 3 : Soil Moisture Sensor Circuit Diagram
Step 4 : Soil Moisture Sensor Arduino Code
void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); } void loop() { // read the input on analog pin 0: int sensorValue = analogRead(A0); Serial.println(sensorValue); delay(500); }
Upload the code to Arduino.
Open the Serial Monitor.
Set the baud rate to 9600.
Now you can see the soil moisture sensor reading in serial monitor.
Below you can see interfacing soil moisture sensor with LCD.
Soil Moisture Sensor Circuit with LCD
- Connect Soil Moisture Sensor AO to A3 of Arduino
- Connect Soil Moisture Sensor Vcc and GND to 5V and GND of Arduino respectively.
- Connect Vcc and GND of LCD to GND and Vcc of Arduino respectively.
- Connect SDA of i2c LCD to A4 of Arduino
- Connect SCL of i2c LCD to A5 of Arduino
- Upload the Code below to Arduino
If you have any queries, feel free to comment below.