

The YF-S401 Water Flow Sensor, manufactured by SEA, is a compact and reliable device designed to measure the flow rate of water in a pipe. It operates using a Hall effect sensor that detects the movement of a rotor within the sensor housing. The sensor outputs a pulse signal proportional to the flow rate, which can be easily interpreted by microcontrollers or other electronic systems.








The following table outlines the key technical details of the YF-S401 water flow sensor:
| Parameter | Specification |
|---|---|
| Manufacturer | SEA |
| Part ID | YF-S401 |
| Operating Voltage | 5V to 18V DC |
| Operating Current | ≤ 15 mA (at 5V DC) |
| Flow Rate Range | 1 to 30 liters per minute (L/min) |
| Output Signal | Pulse signal (square wave) |
| Pulse Frequency | 7.5 Hz per liter per minute (approx.) |
| Maximum Water Pressure | 1.75 MPa |
| Operating Temperature | -25°C to 80°C |
| Sensor Body Material | Nylon (food-grade) |
| Connector Type | 3-pin JST |
The YF-S401 has a 3-pin connector with the following pinout:
| Pin | Name | Description |
|---|---|---|
| 1 | VCC | Power supply input (5V to 18V DC) |
| 2 | GND | Ground |
| 3 | Signal | Pulse output signal proportional to flow rate |
Below is an example of how to interface the YF-S401 with an Arduino UNO to measure and display the flow rate:
// YF-S401 Water Flow Sensor Example Code
// Connect the Signal pin to Arduino digital pin 2
// Connect VCC to 5V and GND to GND on the Arduino
volatile int pulseCount = 0; // Variable to store pulse count
float flowRate = 0.0; // Variable to store flow rate in L/min
unsigned long lastTime = 0; // Variable to store the last time flow was calculated
void setup() {
pinMode(2, INPUT_PULLUP); // Set pin 2 as input with pull-up resistor
attachInterrupt(digitalPinToInterrupt(2), countPulse, RISING);
// Attach interrupt to count pulses on rising edge
Serial.begin(9600); // Initialize serial communication
}
void loop() {
unsigned long currentTime = millis(); // Get current time in milliseconds
if (currentTime - lastTime >= 1000) { // Calculate flow rate every second
noInterrupts(); // Disable interrupts temporarily
flowRate = (pulseCount / 7.5); // Calculate flow rate in L/min
pulseCount = 0; // Reset pulse count
interrupts(); // Re-enable interrupts
Serial.print("Flow Rate: ");
Serial.print(flowRate);
Serial.println(" L/min");
lastTime = currentTime; // Update last time
}
}
// Interrupt service routine to count pulses
void countPulse() {
pulseCount++; // Increment pulse count on each rising edge
}
INPUT_PULLUP mode ensures the signal pin is not floating when no signal is present.No Pulse Signal Output
Inaccurate Flow Rate Readings
Sensor Not Detecting Flow
Water Leakage
Q1: Can the YF-S401 measure other liquids besides water?
A1: The sensor is designed for water and may not provide accurate readings for other liquids. Additionally, non-water liquids may damage the sensor.
Q2: What is the maximum cable length for the signal output?
A2: For best performance, keep the cable length under 20 meters. Use shielded cables for longer distances to reduce noise.
Q3: Can the sensor be used outdoors?
A3: The sensor is not waterproof and should be protected from direct exposure to water or extreme weather conditions.
Q4: How do I calibrate the sensor?
A4: The sensor is pre-calibrated by the manufacturer. If needed, you can adjust the flow rate calculation formula based on your specific setup.
By following this documentation, you can effectively integrate the YF-S401 water flow sensor into your projects for accurate and reliable water flow measurement.