FluidGuard
GitHub Repository :
The FluidGuard: Intelligent Liquid Level Management and Refill Solution is akin to having a smart assistant for effectively managing liquids in tanks and containers. Envision a helpful companion that not only observes fluid levels but also takes proactive measures to prevent wastage and shortages, all the while being remarkably dependable and comprehensible. It tackles the challenges associated with manual fluid level management by seamlessly integrating an array of sensors, microcontrollers, wireless communication modules, and control mechanisms. This integration results in a sophisticated approach to fluid monitoring and regulation. Its significance shines in scenarios where precise fluid level management proves pivotal, such as within industrial, agricultural, and distant settings.
Key Features:
- Real-time Fluid Level Monitoring: This system is engineered to monitor liquid levels across various environments, ranging from water tanks to industrial storage. By constantly gathering data from the fluid level sensor, it achieves precise and up-to-the-minute monitoring of fluid levels.
- Fail-safe Mechanisms: To guarantee the system’s integrity, fail-safe mechanisms are integrated. These mechanisms address potential issues such as data loss or transmission failures, ensuring the system remains operational and dependable.
- Error Detection and Correction: The system’s intelligence extends to error detection and real-time correction. It can identify sensor errors and implement corrective actions, contributing to its reliability and accuracy.
- Wireless Communication: The NRF24L01+ PA/LNA modules serve as the communication backbone between the transmitting and receiving devices. These modules operate on a reliable wireless protocol, enabling seamless data transmission over distances, even in challenging environments.
- Automated Fluid Regulation: Through relay components, the system automatically controls the pump to maintain fluid levels within pre-defined thresholds. This ensures efficient resource utilization and prevents overflows or depletion of the fluid source.
- User-friendly Interface: The project incorporates a 16×2 LCD display that presents fluid levels visually using bars and percentages. This intuitive interface enhances user experience and simplifies the interpretation of fluid data.
- Versatility Across Storage Scenarios: The system’s adaptability makes it suitable for various storage scenarios, including silos and distant locations. Its wireless nature ensures that fluid data can be accessed and managed from a central location, saving time and resources.
Technologies Used:
- Microcontroller (Atmega 328p): The microcontroller serves as the project’s core, processing data from the sensor and facilitating communication with the wireless module.
- Wireless Communication (NRF24L01+ PA/LNA): These wireless modules are responsible for transmitting fluid level data from the transmitting device to the receiving device. The PA/LNA feature enhances the communication range and signal strength.
- Fluid Level Sensor (HC-SR04): The HC-SR04 ultrasonic sensor accurately measures fluid levels. It emits ultrasonic signals and calculates the time taken for the signal to bounce back, providing a precise measurement of the distance to the fluid’s surface.
- User Interface (16×2 LCD Display): The LCD display translates numerical data into visual information, showing fluid levels in both bars and percentages. It offers an accessible way for users to interpret the data.
- Pump Control (Relay): The relay component controls the pump’s operation based on the received fluid level data. It ensures that the fluid level is maintained within the desired range.
Program Details
Transmission Code:
#include <SPI.h>
#include <RF24.h>1
RF24 radio(9, 10); // Set CE and CSN pins for NRF24L01+ module
const byte address[6] = "00001"; // Set the transmitting address as a byte array
const int triggerPin = 6; // Connect the trigger pin of the HC-SR04 to digital pin 2
const int echoPin = 7; // Connect the echo pin of the HC-SR04 to digital pin 3
unsigned long previousMillis = 0; // Stores the previous time
const long interval = 1000; // Interval between measurements in milliseconds
const int numSamples = 5; // Number of distance samples to collect
int distances[numSamples]; // Array to store the distance samples
int currentIndex = 0; // Index of the current distance sample
const int maxDistance = 125; // Maximum distance limit in centimeters
Initialization Section:
- The code begins by including the necessary libraries for the NRF24L01+ wireless module (SPI.h and RF24.h) and setting up the NRF24L01+ module with appropriate pins (CE and CSN).
- A unique transmitting address is defined in the form of a byte array.
- Pins for the HC-SR04 ultrasonic sensor (triggerPin and echoPin) are set up.
- Variables for timing and measurement are initialized, including
previousMillis,interval,numSamples,distances,currentIndex, andmaxDistance.
void setup() {
Serial.begin(115200);
radio.begin();
radio.openWritingPipe(address);
radio.setPALevel(RF24_PA_MAX);
radio.setChannel(75);
radio.setDataRate(RF24_250KBPS);
radio.stopListening();
pinMode(triggerPin, OUTPUT);
pinMode(echoPin, INPUT);
// Initialize the distances array with an initial value
for (int i = 0; i < numSamples; i++) {
distances[i] = -1;
}
}
Setup Function:
Serial.begin(115200);initializes serial communication for debugging purposes.- The NRF24L01+ module is initialized with communication settings, including address, power level, channel, and data rate.
- Pins for trigger and echo are set as OUTPUT and INPUT, respectively.
- The
distancesarray is initialized with -1 values.
void loop() {
unsigned long currentMillis = millis(); // Current time
// Check if the interval has passed
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis; // Update the previous time
long duration, distance;
// Send a pulse to the trigger pin to start the measurement
digitalWrite(triggerPin, LOW);
delayMicroseconds(2);
digitalWrite(triggerPin, HIGH);
delayMicroseconds(10);
digitalWrite(triggerPin, LOW);
// Measure the duration of the pulse from the echo pin
duration = pulseIn(echoPin, HIGH);
// Calculate the distance in centimeters
distance = duration / 58.2;
// Apply error reduction using indexing approach
if (distance >= 2 && distance <= maxDistance) {
distances[currentIndex] = maxDistance - distance; // Reverse the measurement
currentIndex = (currentIndex + 1) % numSamples;
}
// Calculate the average distance
int sum = 0;
int validSamples = 0;
for (int i = 0; i < numSamples; i++) {
if (distances[i] != -1) {
sum += distances[i];
validSamples++;
}
}
int averageDistance = (validSamples > 0) ? (sum / validSamples) : -1;
radio.write(&averageDistance, sizeof(averageDistance)); // Send the average distance value wirelessly to the receiver
Serial.println(averageDistance);
}
}
Loop Function:
- In the loop, the code continuously measures fluid levels using the HC-SR04 sensor at regular intervals defined by
interval. - It calculates the distance using the pulse duration from the sensor.
- An error reduction approach is applied to reverse the measurement if it falls within a valid range.
- The code computes the average distance based on the collected samples.
- The average distance is wirelessly transmitted to the receiving device via the NRF24L01+ module.
- The average distance is also printed to the serial monitor for debugging.
Conclusion:
The Automated Liquid Level Indication and Refilling System is a testament to my proficiency in multiple domains, including microcontroller programming, wireless communication, sensor integration, and control mechanisms. By showcasing this project in my portfolio, I demonstrate my ability to develop innovative solutions that offer practical benefits in real-world scenarios. The fusion of technology, intelligent control, and user-friendly interfaces positions this project as a significant accomplishment in the field of automated fluid management.












