Skip to main content
Version: ACS CC

Water Level Monitoring System

Measures the water level in a container.

info

Author: Calu Andrei-Daniel
GitHub Project Link: https://github.com/UPB-PMRust-Students/proiect-andreic13

Description

The project aims to measure the water level in real time using a Raspberry Pi Pico board and an ultrasonic sensor. The sensor detects the water level by calculating the time it takes for sound waves to travel to the water surface and back, and the result is displayed on an LCD. Additionally, a buzzer alerts when the water level is too high.

Motivation

The idea for this project came from a conversation with a friend who explained how his dad uses a water tank to estimate recent rainfall. This inspired me to create a simple and practical system to automatically measure water levels using a Raspberry Pi Pico and an ultrasonic sensor. In agriculture, depending on the amount of rainfall collected in an initially empty tank, the farmer can decide which type of fieldwork is most suitable. By turning this manual observation into a digital process, the system improves accuracy and convenience, making it a useful tool for small-scale farms and rural applications.

Architecture

Architecture diagram

Main Components used in the Water Level Monitoring System project:

1-Raspberry Pi Pico: Microcontroller unit that processes data from the sensor and controls outputs.

2-Ultrasonic Sensor HC-SR04: Measures the distance to the water surface to determine the water level.

3-LCD Display: Displays the measured water level in real time. Also, prints appropiate messages based on the water level.

4-Buzzer: Emits a sound alert if the water level is too high.

5-Smartphone: Receives water level data via built-in Wi-Fi for remote monitoring.

6-Power Supply: Provides power to the entire circuit.

Log

Week - May

Week - May

Week - May

Hardware

The Raspberry Pi Pico W serves as the core microcontroller for the water level monitoring system. It features built-in Wi-Fi, which allows it to transmit data wirelessly to a smartphone on the same network. The system uses an HC-SR04 ultrasonic sensor to measure the water level in a tank by calculating the distance to the surface. The measured data is displayed on a 16x2 LCD screen using the I2C interface for efficient communication. A buzzer is used to alert the user when water levels fall outside predefined thresholds. The entire setup is powered by a power supply and assembled using a breadboard and jumper wires for quick prototyping.

Schematics

diagram

Bill of Materials

DeviceUsagePrice
Raspberry Pi Pico W x2The microcontroller79,22 RON
HC-SR04+ Ultrasonic SensorMeasures distance14,99 RON
LCD Display (16x2)Displays water level11,00 RON
HC-SR04 Ultrasonic Sensor SupportHolds the sensor4,99 RON
Active Buzzer ModuleSound Alert3,57 RON
Breadboard HQ (830 Points)Prototyping board9,98 RON
Jumper Wires M-F (15 cm, 40p)Connecting components7,99 RON
Resistors (330Ω x10)LCD Backlight, Pull-ups, etc0,15 RON
Resistors (10kΩ x10)LCD Backlight, Pull-ups, etc0,15 RON
Pin Header (2.54mm, 40p, White)Connectors/Pins0,99 RON

Software

LibraryDescriptionUsage
cortex-mLow-level access to Cortex-M processorsProvides core CPU primitives and access
cortex-m-rtCortex-M runtime supportHandles microcontroller startup, vector table, memory setup
embassy-executorAsync task executor for EmbassyManages asynchronous tasks like sensor reading and Wi-Fi communication
embassy-rpEmbassy support for Raspberry Pi RP2040Provides HAL implementations for RP2040 peripherals
embassy-timeTiming utilities for EmbassyProvides async delays, timers, and timeouts
embassy-netTCP/IP network stack for EmbassyEnables Wi-Fi-based communication and networking
embassy-syncSynchronization primitives for EmbassyAsync mutexes, channels, and coordination primitives
embedded-halHardware abstraction layer for embedded systemsStandard blocking traits used by many drivers
embedded-hal-asyncAsynchronous HAL traitsUsed for drivers that support async behavior, like I2C, SPI, etc.
cyw43Wi-Fi driver for CYW43 chips (used by Pico W)Controls the Pico W’s built-in Wi-Fi module
ag-lcdLCD driver with I2C/PCF8574 supportDrives 16x2 LCDs connected via I2C
logLogging facade for RustProvides a universal logging interface for embedded and std environments
defmtEfficient logging for embeddedCompact, structured logging for low-memory targets
defmt-rttRTT target for defmt loggingOutputs logs over RTT for debug probes
panic-probePanic handler with debug outputSends panic messages over defmt for debugging
panic-haltMinimal panic handlerHalts execution on panic without debug output
static_cellStatic allocation utilitiesStatically allocates buffers or singletons needed in no-std environments
heaplessHeapless data structuresProvides Vec, String, etc., that work without dynamic memory
futuresAsync utilities for RustFoundation for writing async logic, required by Embassy and drivers
embedded-graphics2D drawing primitivesUsed for rendering text or graphics on displays
st7789Display driver for ST7789 LCDsDriver for displays often used with Pico Explorer or similar boards
display-interfaceDisplay interface traitsAbstraction layer between graphics drivers and display hardware
byte-slice-castSafe casting between byte slices and arraysUseful for dealing with binary data
micro-randNo-std random number generatorUsed to add randomness, e.g., for simulating events or randomness
shared-busShared I2C/SPI bus managementEnables multiple devices to safely share a bus
no_std_stringsString types for no-std environmentsHelps work with strings when heap allocation isn’t available
  1. Ultrasonic Water Level Indicator using HC-SR04 & Arduino