Water Level Depth Sensor & Tank Overflow Alarm
Track liquid depth across exposed copper sensor traces using corrosion-safe pulsed excitation and multi-zone LEDs.
Monitor reservoir fill height and detect leaks cleanly using an exposed-trace water level sensor module. Just like our soil monitor, you will power the sensor trace grid briefly via D7 only while sampling A0, classify Empty / Low / Medium / High tank levels, and trigger an overflow alarm.
Key Learning Objectives & Robotics Concepts
By building and programming this project, you will master the following core engineering skills:
Power Architecture & Voltage Staging
5V / 3.3V Regulated PowerDriving the water level module's (+) pin from Arduino D7 for 15ms every second keeps current draw tiny (<15mA peak, <0.3mA average) and stops electrolysis from dissolving the sensor traces. NEVER submerge the top header pins or transistor components—only dip the parallel striped gold/tin sensing area! Use pulsed D7 power to prevent trace oxidation.
Bill of Materials (BOM) & Hardware Components
| Component | Specifications & Alternative | Qty | Approx Cost |
|---|---|---|---|
| Arduino Uno R3 | ATmega328P @ 16MHz | 1 | $8.00 |
| Analog Water Level Depth Sensor | 40mm parallel trace grid + NPN amplifier | 1 | $1.20 |
| Green, Yellow, Red LEDs + 220Ω Resistors | 3-level tank status bar | 3 | $0.45 |
| Breadboard & Jumper Wires | 8× breadboard jumpers | 1 | $2.00 |
Electrical & System Architecture
Connect Water Sensor (+) to D7 (switched power), (-) to GND, and (S) Signal to A0. Wire Low/Mid/High LEDs (+220Ω each) to D8, D9, and D10.
Autonomous Behavior & Finite State Machine (FSM)
Deterministic Arduino loop handling Exposed-Trace Analog Water Level Sensor acquisition, filtering, and real-time output updates.
Step-by-Step Physical Assembly & Wiring Tutorial
Follow each of the 5 sequential milestone stages with technical photos, wiring checks, and pre-flight tests.
Observe Immersion Safety Line
Locate the striped sensing lines vs. the upper SMD transistor/header zone.
- Identify the 3 pins: S (Signal), + (VCC), and - (GND).
- Note the horizontal line above the parallel stripes—never let water reach the top components or jumper plugs!
- Prepare a small cup of tap water (pure distilled water barely conducts; normal tap water works great).
Wire Switched Power (D7), Signal (A0) & 3-LED Bar
Connect the sensor and three color-coded level LEDs cleanly.
- Wire Sensor (+) → D7, (-) → GND, and (S) → A0.
- Wire Green LED (+220Ω) to D8, Yellow LED (+220Ω) to D9, and Red LED (+220Ω) to D10.
- Double-check all LED cathodes return to the breadboard GND rail.
Record Dry, Half-Full & Full ADC Readings
Run the diagnostic check while dipping the stripes gradually into tap water.
- Upload the diagnostic snippet and open Serial Monitor.
- Verify dry reading sits near 0–15.
- Dip 1cm, 2cm, and 3.5cm into tap water and note your exact ADC values.
Upload Tank Depth Gauge & Overflow Alarm
Flash the 3-zone bar monitor and watch LEDs climb smoothly as water rises.
- Upload the production sketch below.
- Dip sensor slowly into water: Green lights at LOW, Yellow joins at MID, Red joins at HIGH/OVERFLOW.
- Confirm Serial Monitor reports exact raw ADC and tank zone cleanly.
Verify Leak-Detection Sensitivity
Touch just a single water droplet across the bottom two stripes to confirm instant leak alert.
- Start with a completely dry sensor (0 LEDs lit).
- Touch one drop of water to the bottom traces—confirm instant transition to LOW.
- Dry the board thoroughly before storing.
Subsystem Benchtop Verification Scripts
Test each hardware subsystem independently before deploying the full autonomous firmware.
1Bench Diagnostic: Exposed-Trace Analog Water Level Sensor Hardware Check
Subsystem DiagnosticMinimal standalone sketch to verify pin wiring and signal response for Exposed-Trace Analog Water Level Sensor before running the full project firmware.
// Diagnostic: Pulsed Water Sensor Raw Depth ADC
void setup() { pinMode(7, OUTPUT); Serial.begin(115200); }
void loop() {
digitalWrite(7, HIGH); delay(15);
int v = analogRead(A0);
digitalWrite(7, LOW);
Serial.print("Water Level ADC: "); Serial.println(v);
delay(800);
}Complete Production Firmware
Full working C++ source code with pin mappings, non-blocking timers, and FSM avoidance routines.
/**
* Project 24: Anti-Corrosion Water Level Depth Gauge & Overflow Monitor
* Board: Arduino Uno R3 | Pins: D7 (Switched VCC), A0 (S), D8/D9/D10 (LED Bar)
*/
const uint8_t SENSOR_PWR = 7;
const uint8_t SENSOR_SIG = A0;
const uint8_t LED_LOW = 8;
const uint8_t LED_MID = 9;
const uint8_t LED_HIGH = 10;
const int TH_LOW = 120;
const int TH_MID = 340;
const int TH_HIGH = 500;
int readWaterLevel() {
digitalWrite(SENSOR_PWR, HIGH);
delay(15);
int val = analogRead(SENSOR_SIG);
digitalWrite(SENSOR_PWR, LOW);
return val;
}
void setup() {
pinMode(SENSOR_PWR, OUTPUT);
pinMode(LED_LOW, OUTPUT);
pinMode(LED_MID, OUTPUT);
pinMode(LED_HIGH, OUTPUT);
Serial.begin(115200);
Serial.println(F("Water Level Depth Monitor Ready"));
}
void loop() {
int level = readWaterLevel();
digitalWrite(LED_LOW, level >= TH_LOW ? HIGH : LOW);
digitalWrite(LED_MID, level >= TH_MID ? HIGH : LOW);
digitalWrite(LED_HIGH, level >= TH_HIGH ? HIGH : LOW);
Serial.print(F("Raw ADC: ")); Serial.print(level);
Serial.print(F(" | Tank Zone: "));
if (level >= TH_HIGH) Serial.println(F("HIGH / OVERFLOW ALERT!"));
else if (level >= TH_MID) Serial.println(F("MEDIUM"));
else if (level >= TH_LOW) Serial.println(F("LOW"));
else Serial.println(F("EMPTY / DRY"));
delay(800);
}Firmware Architecture Explanation:
- Energizes the sensor traces for only 15ms per 800ms cycle to maximize trace life.
- Implements a progressive bar-graph output lighting 1, 2, or 3 LEDs across depth thresholds.
- Reports live zone diagnostics clearly over 115200 baud Serial.
Operational Verification & Pin State Matrix
Input Signal vs. System Output Truth Table:
| Input / State | Pin / Signal | Detected Condition | Expected Output |
|---|---|---|---|
| ADC < 120 | Dry Traces | Tank Empty | All LEDs OFF |
| 120 – 339 | Bottom Wet | Low Water Level | Green LED (D8) ON |
| 340 – 499 | Half Submerged | Medium Level | Green + Yellow ON |
| ADC ≥ 500 | Full Immersion | Overflow Warning | All 3 LEDs ON (Red Alert) |
Engineering Troubleshooting Matrix
| Problem | Likely Cause | Diagnostic Check | Engineering Solution |
|---|---|---|---|
| Always reads 0 even when dipped in water | Testing with pure distilled water, or D7 power wire loose | Test with regular tap water and check (+) → D7 | Use tap water and confirm S→A0, +→D7, -→GND. |
| Reads HIGH even after removing from cup | Clinging water film bridging parallel traces | Inspect board surface for droplets | Pat traces dry with tissue or tilt board vertically to drain. |
| Max reading never reaches 500 | Soft tap water has lower electrical conductivity | Record your maximum submerged ADC value | Scale TH_LOW, TH_MID, and TH_HIGH down proportionally. |
Engineering Challenges & Upgrades
Take your build to the next level with these progressive engineering upgrades:
Sound Project 5 piezo buzzer whenever level exceeds TH_HIGH.
Draw a filling rectangular water tank icon live on Project 4 OLED.
Turn on a pump below LOW and shut it off automatically once MID is reached.