YF-S401 Water Flow Sensor – 0.3 to 6 L/min – 1/4″

60,00 DH

Availability:

94 in stock

SKU: 0239 Categories: ,

Description

YF-S401 Water Flow Sensor – 0.3 to 6 L/min – 1/4″

The YF-S401 is a compact flow meter for measuring the instantaneous flow rate and total volume of water moving through a pipe. Its internal turbine drives a Hall-effect sensor that generates electrical pulses proportional to the amount of liquid passing through it.
Compatible with Arduino and many microcontrollers, it is suitable for irrigation systems, water dispensers, coffee machines, home-automation installations, and dosing equipment.

Technical Specifications

  • Model: YF-S401
  • Measurement range: 0.3 to 6 L/min
  • Connection: 1/4 inch
  • Measurement principle: turbine with Hall-effect sensor
  • Output signal: digital pulses
  • Supply voltage: 5 to 18 V DC
  • Minimum voltage: approximately 4.5 V DC
  • Maximum current: approximately 15 mA at 5 V
  • Maximum allowable pressure: 1.75 MPa, approximately 17.5 bar
  • Recommended operating temperature: up to 80 °C
  • Signal duty cycle: 50% ±10%
  • Indicative formula: F = 98 × Q
  • Approximately 5,880 pulses per litre

In the formula, F is the frequency in hertz and Q is the flow rate in litres per minute. These values are given in the YF-S401 technical documentation.

Applications

  • Measuring water consumption
  • Automated irrigation systems
  • Beverage dispensers
  • Coffee machines
  • Automatic tank filling
  • Pump control
  • Cooling circuits
  • Arduino and home-automation projects
  • Detecting absent or interrupted flow

Arduino Mini Tutorial

Wiring
YF-S401 wire Function Arduino Uno/Nano
Red Positive supply 5V
Black Ground GND
Yellow Pulse signal D2

Connect the signal wire to an interrupt-capable pin. On an Arduino Uno or Nano, pin D2 is suitable.

Arduino Code

This program displays the instantaneous flow rate in litres per minute and the total volume that has passed through the sensor.

const byte flowPin = 2;
const float pulsesPerLiter = 5880.0;

volatile unsigned long pulseCount = 0;

unsigned long previousTime = 0;
unsigned long previousPulseCount = 0;
float totalLiters = 0.0;

void countPulse() {
  pulseCount++;
}

void setup() {
  Serial.begin(9600);

  pinMode(flowPin, INPUT_PULLUP);
  attachInterrupt(
    digitalPinToInterrupt(flowPin),
    countPulse,
    FALLING
  );

  previousTime = millis();
}

void loop() {
  unsigned long currentTime = millis();

  if (currentTime - previousTime >= 1000) {
    noInterrupts();
    unsigned long currentPulseCount = pulseCount;
    interrupts();

    unsigned long elapsedTime = currentTime - previousTime;
    unsigned long newPulses =
      currentPulseCount - previousPulseCount;

    float flowRate =
      (newPulses * 60000.0) /
      (pulsesPerLiter * elapsedTime);

    totalLiters =
      currentPulseCount / pulsesPerLiter;

    Serial.print("Debit : ");
    Serial.print(flowRate, 3);
    Serial.print(" L/min | Volume total : ");
    Serial.print(totalLiters, 3);
    Serial.println(" L");

    previousPulseCount = currentPulseCount;
    previousTime = currentTime;
  }
}

Open the Serial Monitor at 9600 baud. When water flows through the sensor, the program displays the instantaneous flow rate and cumulative volume.

Installation

  1. Turn off the water supply and depressurize the pipe.
  2. Install the sensor in the direction indicated by the flow arrow.
  3. Use a suitable 1/4″ hose and fittings.
  4. Seal the connections properly without overtightening the plastic body.
  5. Check for leaks at low pressure.
  6. Then make the electrical connections with the power off.

Where possible, install the sensor in a straight section of pipe. Avoid air bubbles, strong vibration, and placing it immediately next to a bend or pump, as these can affect the measurement.

Recommended Calibration

The 5,880 pulses per litre constant is indicative. To improve accuracy:

  1. Pass exactly one litre of water through the sensor.
  2. Record the number of pulses counted.
  3. Replace 5880.0 in the program with the measured value.
  4. Repeat the test two or three times and use the average.

Precautions

  • Do not exceed a flow rate of 6 L/min.
  • Do not exceed the stated maximum pressure.
  • Do not run the sensor dry for an extended period.
  • Avoid liquids containing particles that could block the turbine.
  • Check material compatibility before using it with liquids other than water.
  • For an ESP32 or another 3.3 V microcontroller, protect the input with an appropriate level-shifting circuit.
  • The maximum pressure is an allowable limit, not a recommended continuous operating pressure.

Thank you for your loyalty!

EN