

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


To design and implement an automated irrigation system that waters plants when the soil is dry and monitors water tank level using an ultrasonic sensor.
Arduino Uno (ATmega328P) is used because it is easy to program, has analog and digital pins, and is perfect for sensor-based projects.
Soil Moisture Sensor: Measures voltage across soil. Wet soil conducts more, giving high analog value. Dry soil has high resistance, low value.
Ultrasonic Sensor: Sends ultrasonic pulse. Measures time to receive echo. Distance = (time × 0.0343) / 2.
int soilPin = A0; int pumpRelay = 7; int trigPin = 9; int echoPin = 8; int dryThreshold = 500; int waterLevelLimit = 10;
void setup() { Serial.begin(9600); pinMode(pumpRelay, OUTPUT); pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); digitalWrite(pumpRelay, LOW); }
void loop() { int soilValue = analogRead(soilPin); long duration; int distance;
digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH); distance = duration * 0.034 / 2;
if (soilValue > dryThreshold && distance > waterLevelLimit) { digitalWrite(pumpRelay, HIGH); } else { digitalWrite(pumpRelay, LOW); } delay(2000); }
The soil sensor reads analog value to detect dryness. The ultrasonic sensor checks if tank has enough water.