Interfacing Waterflow sensor with Bharat Pi
Introduction of BHARATPI:
Introduction of Water Flow Sensor:
The sensor comes with
three wires: red (5-24VDC power), black (ground), and yellow (Hall effect pulse
output). By counting the pulses from the output of the sensor, you can easily calculate
the water flow rate. Each pulse is approximately 2.25 milliliters. Note this
isn’t a precision sensor, and the pulse rate does vary a bit depending on the
flow rate, fluid pressure, and sensor orientation. It will need careful
calibration if better than 10% precision is required.
This sensor sits in line with your water line and contains a pinwheel sensor to measure how much liquid has moved through it. There’s an integrated magnetic hall effect sensor that outputs an electrical pulse with every revolution. The hall effect sensor is sealed from the water pipe and allows the sensor to stay safe and dry.
STEP 1:How Water Flow
Sensor Works?
The
working of the YFS201 water flow sensor is simple to understand. The water flow
sensor works on the principle of hall effect. Hall effect is the production of
the potential difference across an electric conductor when a magnetic field is
applied in the direction perpendicular to that of the flow of current. The
water flow sensor is integrated with a magnetic hall effect sensor, which
generates an electric pulse with every revolution. Its design is in such a way
that the hall effect sensor is sealed off from the water, and allows the sensor
to stay safe and dry.
STEP
2:Water Flow Sensor Pinout
connect
the sensor's red wire (VCC) to 5V on the ESP32.
Connect the sensor's
black wire (GND) to GND on the ESP32.
Connect the sensor's
yellow wire (signal) to a GPIO pin on the ESP32 (pin 33)
STEP 3:Requirements
·
Water Flow Sensor
· Connecting wires
Arduino IDE
STEP
4:Interfacing Water Flow Sensor with Bharathpi
STEP 5: Source code and Programming
const int flowSensorPin = 33; // Replace with the GPIO pin
you are using
volatile int flowCount = 0;
unsigned long lastMillis = 0;
float flowRate = 0.0;
void IRAM_ATTR pulseCounter() {
flowCount++;
}
void setup() {
pinMode(flowSensorPin,
INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(flowSensorPin), pulseCounter, RISING);
Serial.begin(115200);
}
void loop() {
unsigned long currentMillis = millis();
if (currentMillis - lastMillis >=
1000) { // Update every 1 second
detachInterrupt(digitalPinToInterrupt(flowSensorPin)); // Disable interrupts
flowRate = (float)flowCount * 60.0 / 7.5; // Calculate flow rate (adjust
the divisor based on your sensor's specifications)
flowCount = 0;
lastMillis = currentMillis;
attachInterrupt(digitalPinToInterrupt(flowSensorPin), pulseCounter, RISING); // Re-enable interrupts
Serial.print("Flow Rate: ");
Serial.print(flowRate);
Serial.println(" L/min");
}
}
STEP 6:Application
1.Home
Water Consumption Monitoring: Water flow sensors are used to monitor water
usage in homes, helping residents conserve water and detect leaks.
2.Industrial
Process Control: They are essential in industries like manufacturing and
chemical processing to control and optimize water flow in various processes.
3.Irrigation
Systems: Water flow sensors ensure efficient irrigation by measuring and
controlling the water flow in agricultural fields and gardens.
4.Aquariums:
They are used to regulate water flow and maintain water quality in fish
tanks and aquariums.
VIDEO:
Comments
Post a Comment