Real-time automated filling system with intelligent level detection and precision flow control.
SmartFlow is a real-time automated filling system built in C++ and running natively on Linux (Raspberry Pi OS) on a Raspberry Pi 5. It leverages the Pi's GPIO interface to communicate with level sensors and control pumps/valves, delivering a fully automated, precise, and intelligent filling solution — with no manual intervention required.
- 🔄 Real-Time Level Monitoring — Continuous polling of liquid levels via GPIO-connected sensors
- 🧠 Smart Level Detection — Threshold-based logic triggers automatic fill and stop actions
- ⚙️ Automated Flow Control — Relay-controlled pump and valve management
- 📊 Live Terminal Dashboard — Real-time status output directly in the Linux terminal
- 🔔 Alerts & Notifications — System warnings for overflow, underflow, and sensor faults
- 📁 Data Logging — CSV-based event and fill history logging
- 🔌 GPIO Native Integration — Direct hardware control via
lgpio/gpiodon Raspberry Pi 5 - 🧵 Multithreaded Architecture — Sensor reading and control logic run on separate threads
| Layer | Technology |
|---|---|
| Language | C++17 |
| Hardware | Raspberry Pi 5 |
| Operating System | Raspberry Pi OS (Linux) |
| GPIO Library | lgpio / libgpiod |
| Build System | CMake 3.16+ |
| Level Sensor | Ultrasonic (HC-SR04) / Float Switch |
| Actuator Control | 5V Relay Module (Pump & Valve) |
| Communication | I2C / GPIO Digital Pins |
| Data Logging | CSV file logging OR DB for IoT |
| Component | Details |
|---|---|
| Raspberry Pi 5 | 4GB RAM |
| Ultrasonic Sensor | HC-SR04 (level detection) |
| Float Switch | Optional backup level detection |
| Relay Module | 5V single or dual channel |
| Water Pump | 5V/12V DC submersible pump |
| Solenoid Valve | 12V normally-closed valve |
| Power Supply | 5V 5A USB-C (Pi 5) + 12V for actuators |
| GPIO Pin | Component | Direction |
|---|---|---|
| GPIO 17 | HC-SR04 TRIG | Output |
| GPIO 27 | HC-SR04 ECHO | Input |
| GPIO 22 | Relay (Pump) | Output |
| GPIO 23 | Relay (Valve) | Output |
| GPIO 24 | Float Switch | Input |
⚠️ Always use a voltage divider on the ECHO pin (HC-SR04 outputs 5V; RPi GPIO is 3.3V max).
Ensure your Raspberry Pi 5 is running Raspberry Pi OS (Linux) and has the following installed:
sudo apt update && sudo apt upgrade -y
sudo apt install -y cmake g++ libgpiod-dev liblgpio-devgit clone https://github.com/Eng5220/SmartFlowX.git
cd smartflowmkdir build && cd build
cmake ..
make -j4sudo ./smartflow
⚠️ sudois required for GPIO access on Raspberry Pi OS.
- Sensor reads liquid level every 500ms via the HC-SR04 ultrasonic sensor on GPIO
- Detection Logic compares the reading against
threshold_highandthreshold_low - Controller dispatches commands to start or stop the pump/valve via relay
- Actuator toggles GPIO pins to physically control the pump and solenoid valve
- Logger records every fill event, level reading, and system alert to a CSV file
- Terminal Dashboard prints live status, current fill %, and system state
cd build
make test
./smartflow_testsContributions are welcome! Please follow these steps:
- Fork the repository
- Create a new branch (
git checkout -b feature/your-feature) - Commit your changes (
git commit -m 'Add your feature') - Push to the branch (
git push origin feature/your-feature) - Open a Pull Request
This project is licensed under the MIT License.
SmartFlow Team
- GitHub: @Eng5220/SmartFlowX
- TEAM:20
Built with precision on Raspberry Pi 5. Powered by C++ and Linux. 🐧💡