MyRoboPathOpen Robotics Lab
Arduino Uno #24 of 35
Est. 0.5 Hours
Budget: $2 - $4
Beginner

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.

Arduino Uno R3Water Level SensorPulsed D7 PowerTank Level ZonesOverflow Alarm
Water Level Depth Sensor & Tank Overflow Alarm Blueprint
Water Level Depth Sensor & Tank Overflow AlarmCAD Blueprint

Key Learning Objectives & Robotics Concepts

By building and programming this project, you will master the following core engineering skills:

1Understand how interleaved ground and power traces create a variable liquid resistor coupled to an NPN transistor.
2Protect conductive sensing traces from galvanic decay with pulsed GPIO excitation.
3Map nonlinear wet-depth ADC curves into clean discrete tank states (EMPTY, LOW, MEDIUM, FULL).
4Design a clear visual level gauge with overflow alerting.

Power Architecture & Voltage Staging

5V / 3.3V Regulated Power

Driving 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.

Water Level Depth Sensor & Tank Overflow Alarm Power Architecture Schematic
Figure: Regulated Arduino Uno supply rails, current budget, and component protection.Power Schematic

Bill of Materials (BOM) & Hardware Components

Bill of Materials for Water Level Depth Sensor & Tank Overflow Alarm
ComponentSpecifications & AlternativeQtyApprox Cost
Arduino Uno R3ATmega328P @ 16MHz1$8.00
Analog Water Level Depth Sensor40mm parallel trace grid + NPN amplifier1$1.20
Green, Yellow, Red LEDs + 220Ω Resistors3-level tank status bar3$0.45
Breadboard & Jumper Wires8× breadboard jumpers1$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.

Figure: Complete Arduino Uno R3 pin-to-pin wiring schematic for Water Level Depth Sensor & Tank Overflow Alarm.
Figure: Complete Arduino Uno R3 pin-to-pin wiring schematic for Water Level Depth Sensor & Tank Overflow Alarm.Wiring Schematic

Autonomous Behavior & Finite State Machine (FSM)

Deterministic Arduino loop handling Exposed-Trace Analog Water Level Sensor acquisition, filtering, and real-time output updates.

Figure: Firmware execution flow and state transitions for Water Level Depth Sensor & Tank Overflow Alarm.
Figure: Firmware execution flow and state transitions for Water Level Depth Sensor & Tank Overflow Alarm.Control Algorithm

Step-by-Step Physical Assembly & Wiring Tutorial

Follow each of the 5 sequential milestone stages with technical photos, wiring checks, and pre-flight tests.

1

Observe Immersion Safety Line

Duration: 5 Mins

Locate the striped sensing lines vs. the upper SMD transistor/header zone.

Water Level Depth Sensor & Tank Overflow Alarm hardware layout diagram
Stage 1: Exposed-Trace Analog Water Level Sensor hardware inspection & pinout overview.Stage 1 Diagram
Step Action Checklist:
  • 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).
Engineering & Tuning Tip: Wrapping the top header area in silicone or heat-shrink protects it from accidental splashes during tank demos.
2

Wire Switched Power (D7), Signal (A0) & 3-LED Bar

Duration: 10 Mins

Connect the sensor and three color-coded level LEDs cleanly.

Water Level Depth Sensor & Tank Overflow Alarm breadboard wiring check diagram
Stage 2: Breadboard layout & Arduino Uno pin-to-pin wiring audit.Stage 2 Diagram
Step Action Checklist:
  • 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.
Engineering & Tuning Tip: Notice the water sensor output rises with depth (0 dry → ~550–700 fully immersed), opposite to resistive soil forks!
3

Record Dry, Half-Full & Full ADC Readings

Duration: 5 Mins

Run the diagnostic check while dipping the stripes gradually into tap water.

Water Level Depth Sensor & Tank Overflow Alarm power rail protection diagram
Stage 3: Supply rail check (Switched D7 Excitation (5V pulsed 15ms)) and circuit protection verification.Stage 3 Diagram
Step Action Checklist:
  • 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.
Engineering & Tuning Tip: Water mineral content varies by city—adjust LOW_TH / MID_TH / HIGH_TH to match your local tap water.
4

Upload Tank Depth Gauge & Overflow Alarm

Duration: 10 Mins

Flash the 3-zone bar monitor and watch LEDs climb smoothly as water rises.

Water Level Depth Sensor & Tank Overflow Alarm serial telemetry verification diagram
Stage 4: Firmware upload & 115200 baud Serial Monitor verification.Stage 4 Diagram
Step Action Checklist:
  • 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.
Engineering & Tuning Tip: Always blot water drops off the stripes with a paper towel when testing "Empty" so surface moisture bridges clear immediately.
5

Verify Leak-Detection Sensitivity

Duration: 5 Mins

Touch just a single water droplet across the bottom two stripes to confirm instant leak alert.

Water Level Depth Sensor & Tank Overflow Alarm live operational logic diagram
Stage 5: Live operational logic flow & calibration verification.Stage 5 Diagram
Step Action Checklist:
  • 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.
Engineering & Tuning Tip: This exact circuit works wonderfully under a washing machine or aquarium stand as a floor-leak sentinel!

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 Diagnostic

Minimal standalone sketch to verify pin wiring and signal response for Exposed-Trace Analog Water Level Sensor before running the full project firmware.

Arduino IDE Diagnostic ScriptC++ / Arduino
// 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);
}
Expected Output: 0–10 when dry; climbs smoothly through ~250 (low), ~450 (mid), ~620 (full).

Complete Production Firmware

Full working C++ source code with pin mappings, non-blocking timers, and FSM avoidance routines.

arduino_uno_water_level_depth_sensor.ino
arduino_uno_water_level_depth_sensor.inoArduino C++
/**
 * 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

1Double-check all 4 Arduino Uno pin connections against the wiring schematic before plugging in USB.
2Upload the Bench Diagnostic sketch first and confirm Serial Monitor at 115200 baud matches: 0–10 when dry; climbs smoothly through ~250 (low), ~450 (mid), ~620 (full).
3Upload the complete production sketch and verify every condition in the operational truth table below.

Input Signal vs. System Output Truth Table:

Operational truth table for Water Level Depth Sensor & Tank Overflow Alarm
Input / StatePin / SignalDetected ConditionExpected Output
ADC < 120Dry TracesTank EmptyAll LEDs OFF
120 – 339Bottom WetLow Water LevelGreen LED (D8) ON
340 – 499Half SubmergedMedium LevelGreen + Yellow ON
ADC ≥ 500Full ImmersionOverflow WarningAll 3 LEDs ON (Red Alert)

Engineering Troubleshooting Matrix

Engineering troubleshooting matrix for Water Level Depth Sensor & Tank Overflow Alarm
ProblemLikely CauseDiagnostic CheckEngineering Solution
Always reads 0 even when dipped in waterTesting with pure distilled water, or D7 power wire looseTest with regular tap water and check (+) → D7Use tap water and confirm S→A0, +→D7, -→GND.
Reads HIGH even after removing from cupClinging water film bridging parallel tracesInspect board surface for dropletsPat traces dry with tissue or tilt board vertically to drain.
Max reading never reaches 500Soft tap water has lower electrical conductivityRecord your maximum submerged ADC valueScale TH_LOW, TH_MID, and TH_HIGH down proportionally.

Engineering Challenges & Upgrades

Take your build to the next level with these progressive engineering upgrades:

Level 1Audible Overflow Siren

Sound Project 5 piezo buzzer whenever level exceeds TH_HIGH.

Level 2OLED Water Tank Animation

Draw a filling rectangular water tank icon live on Project 4 OLED.

Level 3Auto-Refill Sump Controller

Turn on a pump below LOW and shut it off automatically once MID is reached.