Stufin
Home Quick Cart Profile

1/4 Inch Water Flow Sensor YF - S402

Buy Now

Component Name

1/4 Inch Water Flow Sensor YF-S402

Overview

The 1/4 Inch Water Flow Sensor YF-S402 is a digital flow sensor designed to measure the flow rate of liquids, specifically water, in a piping system. This sensor is widely used in various IoT applications, including industrial automation, water metering, and irrigation systems.

Functionality

The YF-S402 Water Flow Sensor measures the flow rate of water by detecting the frequency of a rotor spinning inside the sensor body. When water flows through the sensor, it rotates the rotor, generating a pulse signal proportional to the flow rate. The sensor then converts this pulse signal into a digital output, which can be easily interfaced with microcontrollers, computers, or other IoT devices.

Key Features

  • High Accuracy: The YF-S402 Water Flow Sensor provides accurate flow rate measurements with an error margin of 5% over a wide range of flow rates.
  • Digital Output: The sensor outputs a digital pulse signal, making it easy to interface with microcontrollers, computers, or other IoT devices.
  • 1/4 Inch Pipe Fitting: The sensor has a 1/4 inch pipe fitting, making it suitable for use in small-diameter piping systems.
  • Wide Flow Rate Range: The YF-S402 can measure flow rates from 0.5 to 20 liters per minute (L/min).
  • Low Pressure Drop: The sensor is designed to minimize pressure drop, ensuring minimal impact on the piping system.
  • Rugged Construction: The sensor body is made of brass, ensuring durability and resistance to corrosion.
  • Easy Installation: The YF-S402 is simple to install, with a straightforward pipe connection and digital output wiring.
  • Power Supply: The sensor operates on a 5-24V DC power supply, making it suitable for use in a wide range of IoT applications.

Technical Specifications

Operating Temperature

-20C to 80C (-4F to 176F)

Storage Temperature

-30C to 90C (-22F to 194F)

Flow Rate Range

0.5-20 L/min

Accuracy

5% FS

Repeatability

1% FS

Response Time

<1 second

Signal Output

Digital pulse signal

Power Supply

5-24V DC

Current Consumption

<15mA

Connection Type

1/4 inch pipe fitting

Material

Brass

Dimensions

40x30x20 mm (1.57x1.18x0.79 in)

Applications

The 1/4 Inch Water Flow Sensor YF-S402 is ideal for various IoT applications, including

Industrial automation and process control

Water metering and leak detection

Irrigation systems and agricultural automation

HVAC and plumbing systems

Medical and laboratory equipment

Certifications and Compliance

The YF-S402 Water Flow Sensor meets the following certifications and compliance standards

CE certified

RoHS compliant

REACH compliant

Warranty and Support

The YF-S402 Water Flow Sensor is backed by a 12-month warranty and supported by a dedicated technical support team.

Pin Configuration

  • 1/4 Inch Water Flow Sensor YF-S402 Pinout Explanation
  • The 1/4 Inch Water Flow Sensor YF-S402 is a popular IoT component used to measure the flow rate of water in various applications, including industrial, commercial, and residential settings. The sensor has 3 pins, which are explained below:
  • Pinout Structure:
  • Pin 1: VCC (Power Supply)
  • + Function: Provides power to the sensor
  • + Voltage: Typically 5V DC (but can operate within 4.5V to 5.5V range)
  • + Connection: Connect to a 5V power supply or a microcontroller's VCC pin
  • Pin 2: GND (Ground)
  • + Function: Provides a ground connection for the sensor
  • + Connection: Connect to a ground pin on the microcontroller or a common ground point
  • Pin 3: OUT (Output)
  • + Function: Provides a pulse output signal proportional to the flow rate of water
  • + Signal: The output signal is a frequency-modulated pulse signal, with the frequency directly proportional to the flow rate
  • + Connection: Connect to a digital input pin on a microcontroller or a pulse counter to measure the flow rate
  • Connection Suggestions:
  • When connecting the sensor to a microcontroller, use a breadboard or a PCB with a suitable layout to ensure secure connections.
  • Use a 10k pull-up resistor between the OUT pin and VCC to ensure a stable output signal.
  • For noise reduction, add a 100nF capacitor between the OUT pin and GND.
  • When using the sensor with an Arduino board, connect the VCC pin to the 5V pin, GND to GND, and OUT to a digital input pin (e.g., D2).
  • Important Notes:
  • Ensure the sensor is powered with a stable 5V DC supply to maintain accuracy and reliability.
  • Avoid connecting the sensor to a power supply with high ripple or noise, as this can affect the accuracy of the measurements.
  • The sensor's output frequency range is 0-100 Hz, with 1 pulse per liter per minute. You may need to use a pulse counter or a frequency-to-analog converter to process the output signal depending on your application.

Code Examples

Component Documentation: 1/4 Inch Water Flow Sensor YF-S402
Overview
The 1/4 Inch Water Flow Sensor YF-S402 is a microcontroller-compatible sensor designed to measure the flow rate of water or other liquids. It is commonly used in various IoT applications such as smart home automation, industrial automation, and water management systems.
Technical Specifications
Measuring range: 1-30 liters per minute
 Accuracy: 5%
 Sensor type: Hall effect
 Output: Digital pulse output (high-frequency signal)
 Power supply: 5V DC
 Interface: 3-pin connector (VCC, GND, OUT)
 Operating temperature: -25C to 80C
Connecting the Sensor
To connect the sensor to a microcontroller or a single-board computer, follow these steps:
1. Connect the VCC pin to a 5V power supply.
2. Connect the GND pin to a ground pin on the microcontroller or single-board computer.
3. Connect the OUT pin to a digital input pin on the microcontroller or single-board computer.
Code Examples
### Example 1: Using the YF-S402 with Arduino Uno
This example demonstrates how to use the YF-S402 with an Arduino Uno board to measure the water flow rate and display it on the serial monitor.
```c++
const int flowSensorPin = 2;  // Digital input pin for the sensor output
void setup() {
  Serial.begin(9600);
  pinMode(flowSensorPin, INPUT);
}
void loop() {
  int pulseCount = 0;
  unsigned long startTime = millis();
  
  while (millis() - startTime < 1000) {
    if (digitalRead(flowSensorPin) == HIGH) {
      pulseCount++;
    }
  }
  
  float flowRate = (pulseCount / 7.5);  // Calibration factor: 1 liter per minute = 7.5 pulses per second
  Serial.print("Flow rate: ");
  Serial.print(flowRate);
  Serial.println(" liters per minute");
  delay(1000);
}
```
### Example 2: Using the YF-S402 with Raspberry Pi (Python)
This example demonstrates how to use the YF-S402 with a Raspberry Pi single-board computer to measure the water flow rate and display it on the console.
```python
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
flowSensorPin = 17  # GPIO pin for the sensor output
GPIO.setup(flowSensorPin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
while True:
    pulseCount = 0
    startTime = time.time()
    
    while time.time() - startTime < 1:
        if GPIO.input(flowSensorPin) == GPIO.HIGH:
            pulseCount += 1
            
    flowRate = pulseCount / 7.5  # Calibration factor: 1 liter per minute = 7.5 pulses per second
    print("Flow rate: {:.2f} liters per minute".format(flowRate))
    time.sleep(1)
```
### Example 3: Using the YF-S402 with ESP32 (MicroPython)
This example demonstrates how to use the YF-S402 with an ESP32 board to measure the water flow rate and display it on the serial console.
```python
import machine
import time
flowSensorPin = machine.Pin(32, machine.Pin.IN)  # GPIO pin for the sensor output
while True:
    pulseCount = 0
    startTime = time.time()
    
    while time.time() - startTime < 1:
        if flowSensorPin.value() == 1:
            pulseCount += 1
            
    flowRate = pulseCount / 7.5  # Calibration factor: 1 liter per minute = 7.5 pulses per second
    print("Flow rate: {:.2f} liters per minute".format(flowRate))
    time.sleep(1)
```
Note: In all examples, the calibration factor (7.5 pulses per second per liter per minute) may need to be adjusted based on the specific application and sensor characteristics.