

The YF-B7 is a water flow sensor manufactured by Seeed Studio, with the part ID Y7-B7. It is designed to measure the flow rate of liquids using a turbine mechanism. As liquid flows through the sensor, it spins an internal rotor, which generates a series of electrical pulses. These pulses can be read by a microcontroller to calculate the flow rate in liters per minute (L/min).
This sensor is widely used in applications such as water dispensers, irrigation systems, liquid flow monitoring, and industrial fluid control systems. Its compact design and reliable performance make it suitable for both hobbyist and professional projects.








Below are the key technical details of the YF-B7 flow sensor:
| Parameter | Value |
|---|---|
| Operating Voltage | 5V to 18V DC |
| Output Signal | Pulse (Square Wave) |
| Flow Rate Range | 1 to 30 L/min |
| Accuracy | ±5% |
| Maximum Working Pressure | ≤1.75 MPa |
| Operating Temperature | -25°C to 80°C |
| Pulse Frequency Formula | Flow Rate (L/min) = Pulse Frequency / 7.5 |
| Connector Type | 3-pin JST |
| Material | Plastic (Nylon) |
The YF-B7 flow sensor has a 3-pin JST connector. The pinout is as follows:
| Pin | Name | Description |
|---|---|---|
| 1 | VCC | Power supply input (5V to 18V DC) |
| 2 | GND | Ground connection |
| 3 | Signal | Pulse output signal (connect to microcontroller pin) |
Flow Rate (L/min) = Pulse Frequency / 7.5 to calculate the flow rate.Below is an example of how to use the YF-B7 flow sensor with an Arduino UNO to measure and display the flow rate:
// YF-B7 Flow Sensor Example Code for Arduino UNO
// Measures and displays the flow rate in liters per minute (L/min)
volatile int pulseCount = 0; // Variable to store pulse count
float flowRate = 0.0; // Variable to store flow rate
unsigned long lastTime = 0; // Variable to store the last time measurement
const int sensorPin = 2; // Pin connected to the Signal pin of the sensor
void setup() {
pinMode(sensorPin, INPUT_PULLUP); // Set sensor pin as input with pull-up
attachInterrupt(digitalPinToInterrupt(sensorPin), pulseCounter, RISING);
Serial.begin(9600); // Initialize serial communication
}
void loop() {
unsigned long currentTime = millis();
// Calculate flow rate every second
if (currentTime - lastTime >= 1000) {
detachInterrupt(digitalPinToInterrupt(sensorPin)); // Disable interrupt
flowRate = (pulseCount / 7.5); // Calculate flow rate in L/min
Serial.print("Flow Rate: ");
Serial.print(flowRate);
Serial.println(" L/min");
pulseCount = 0; // Reset pulse count
lastTime = currentTime; // Update last time
attachInterrupt(digitalPinToInterrupt(sensorPin), pulseCounter, RISING);
}
}
// Interrupt service routine to count pulses
void pulseCounter() {
pulseCount++;
}
INPUT_PULLUP mode is used to ensure a stable signal from the sensor.No Output Signal:
Inaccurate Flow Rate:
Flow Rate = Pulse Frequency / 7.5 is used.Sensor Not Responding:
Can the YF-B7 measure other liquids besides water?
What is the maximum cable length for the sensor?
Can I use the YF-B7 with a 3.3V microcontroller?
By following this documentation, you can effectively integrate the YF-B7 flow sensor into your projects and troubleshoot common issues.