Lab set Program-6
Develop a program to classify dry and wet waste with the Moisture sensor (DHT22).
Important Note:
-
In real life, a Soil Moisture Sensor is used to detect wet/dry conditions.
-
Tinkercad does not provide a Soil Moisture sensor or DHT22 directly.
-
But we can simulate moisture detection using a Potentiometer as a replacement (to act like varying soil/moisture resistance).
Objective
To develop an Arduino program that classifies dry and wet waste using a moisture sensor (simulated with a potentiometer in Tinkercad) and displays the result through LEDs.
Learning Outcomes
After completing this experiment, students will be able to:
-
Understand how a moisture sensor works (wet waste = high moisture, dry waste = low moisture).
-
Simulate unavailable sensors in Tinkercad using alternatives (here, potentiometer).
-
Write Arduino programs to classify sensor data.
-
Apply IoT-based waste classification for smart cities.
Components (from Tinkercad Palette)
-
Arduino UNO board
-
Potentiometer (simulated moisture sensor, connected to A0)
-
2 LEDs (Red = Dry waste, Green = Wet waste)
-
220Ω resistors × 2
-
Breadboard
-
Jumper wires
Circuit Wiring
-
Potentiometer (Moisture Sensor substitute)
-
One outer leg → 5V
-
Other outer leg → GND
-
Middle pin → A0
-
-
LEDs
-
Green LED (Wet Waste) → Pin 9 (with 220Ω resistor to GND)
-
Red LED (Dry Waste) → Pin 10 (with 220Ω resistor to GND)
Arduino Sketch
int moisturePin = A0; // Potentiometer as moisture sensor
int greenLED = 9; // Wet waste indicator
int redLED = 10; // Dry waste indicator
int moistureValue = 0;
void setup() {
pinMode(greenLED, OUTPUT);
pinMode(redLED, OUTPUT);
Serial.begin(9600);
}
void loop() {
moistureValue = analogRead(moisturePin);
Serial.print("Moisture Value: ");
Serial.println(moistureValue);
if (moistureValue > 600) { // High moisture = wet waste
digitalWrite(greenLED, HIGH);
digitalWrite(redLED, LOW);
} else { // Low moisture = dry waste
digitalWrite(greenLED, LOW);
digitalWrite(redLED, HIGH);
}
delay(500);
}
How It Works
-
The potentiometer simulates a moisture sensor:
-
Turning it one way increases analog value → simulating wet waste.
-
Turning the other way decreases value → simulating dry waste.
-
-
Arduino reads analog values (0–1023).
-
Threshold (
600) decides classification:-
Above 600 = Wet Waste → Green LED ON.
-
Below 600 = Dry Waste → Red LED ON.
-
Common Mistakes & Quick Fixes
-
Forgetting to connect potentiometer middle pin to A0 → always 0 reading.
-
Not using a resistor with LEDs → LED may burn out.
-
Using very small threshold → unstable switching.
Viva / Check-Your-Understanding
-
What is the principle of a soil/moisture sensor?
-
Why do we use a potentiometer in Tinkercad instead of a moisture sensor?
-
How does Arduino distinguish between wet and dry waste?
-
What real-world applications can use this system?
Extensions (Mini-Tasks)
-
Add a buzzer to beep when wet waste is detected.
-
Use Serial Plotter to visualize moisture changes.
-
Classify three levels: Dry, Moist, and Wet using multiple thresholds.
Lab Record (Suggested Headings)
-
Title
-
Objective
-
Components Used
-
Circuit Diagram (Tinkercad screenshot)
-
Arduino Program
-
Output

Comments
Post a Comment