BiotronicMaiker
Published © CC BY

Soil Moisture Sensor

My first Arduino biology project

BeginnerFull instructions provided1 hour293
Soil Moisture Sensor

Things used in this project

Hardware components

Arduino Nano
×1
LM393 3.3V-5V Soil Moisture Detect Sensor
×1
Red LED-Chanzon 60pcs 5mm LED Diode Lights Assortment Kit
×1
ELEGOO 120pcs Multicolored Dupont Wire
ELEGOO 120pcs Multicolored Dupont Wire
×1
USB-A to B Cable
USB-A to B Cable
×1
MCIGICM 400 Points Solderless Breadboard
×1

Software apps and online services

Arduino IDE
Arduino IDE
Google Gemini

Story

Read more

Schematics

Layout for Soil Moisture Sensor Project

Follow the diagram to connect everything.

Code

soil_moisture_sensor.ino

C/C++
Here is the code I used
// Define the pins 
int sensorPin = A0; 
int ledPin = 7; 
 
// Variables to store sensor value 
int sensorValue = 0; 
 
void setup() { 
// Initialize serial communication at 9600 baud rate 
Serial.begin(9600); 
 
// Initialize the LED pin as an output 
pinMode(ledPin, OUTPUT); 
} 
 
void loop() { 
// Read the analog value from the sensor 
sensorValue = analogRead(sensorPin); 
 
// Print the sensor value to the Serial Monitor 
Serial.print("Soil Moisture Value: "); 
Serial.println(sensorValue); 
 
// Check if the soil is dry 
if (sensorValue > 500) { 
// Turn the LED on 
digitalWrite(ledPin, HIGH); 
} else { 
// Turn the LED off 
digitalWrite(ledPin, LOW); 
} 
 
// Wait for a second before taking another reading 
delay(1000); 
} 

Credits

BiotronicMaiker
2 projects • 2 followers
Contact

Comments

Please log in or sign up to comment.