Stufin
Home Quick Cart Profile

1/8 Inch Water Flow Sensor YF-S401

Buy Now on Stufin

Component Name

1/8 Inch Water Flow Sensor YF-S401

Overview

The 1/8 Inch Water Flow Sensor YF-S401 is a digital flow sensor designed to measure the flow rate of liquids, specifically water, in industrial, commercial, and residential applications. This sensor is ideal for monitoring water usage, detecting leaks, and optimizing water resource allocation in various systems.

Functionality

The YF-S401 sensor measures the flow rate of water by detecting the rotational speed of a magnetic-driven rotor, which is proportional to the flow rate. The sensor outputs a digital pulse signal, allowing for easy integration with microcontrollers, Arduino boards, and other electronic devices.

Key Features

  • Flow Rate Measurement: The sensor measures flow rates up to 30 liters per minute (L/min) with an accuracy of 5% of the reading.
  • Digital Output: The sensor provides a digital pulse output signal, which can be easily read and processed by microcontrollers and other digital devices.
  • Magnetic Rotor: The sensor features a magnetic-driven rotor that rotates in proportion to the flow rate, ensuring high accuracy and reliability.
  • 1/8 Inch Threaded Interface: The sensor has a 1/8 inch threaded interface, making it easy to install and connect to pipes and tubing.
  • Low Power Consumption: The sensor operates on a low power consumption of 5V DC, making it suitable for battery-powered applications.
  • Wide Operating Range: The sensor operates within a wide temperature range of 0C to 80C (32F to 176F), making it suitable for various environmental conditions.
  • IP67 Rated: The sensor is IP67 rated, providing protection against dust and water ingress, ensuring reliable operation in harsh environments.
  • Simple Installation: The sensor is easy to install, with a simple thread-in design that eliminates the need for complex plumbing or fabrication.

Flow Rate Range

0.5-30 L/min

Accuracy

5% of reading

Output Signal

Digital pulse signal

Output Frequency

1-100 Hz (dependent on flow rate)

Supply Voltage

5V DC

Current Consumption

<20 mA

Operating Temperature

0C to 80C (32F to 176F)

Storage Temperature

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

Humidity

0% to 80% RH (non-condensing)

Thread Size

1/8 inch

Material

Brass with PVC or POM options

Weight

approximately 50g

Dimensions

22 mm x 17 mm x 14 mm (L x W x H)

CE Marking

Complies with EU health, safety, and environmental protection standards

RoHS Compliance

Complies with EU restriction of hazardous substances in electrical and electronic equipment

UL and cUL Certifications

Complies with US and Canadian safety standards for industrial control equipment

Industrial Automation

Monitor water usage and detect leaks in industrial processes and equipment

Commercial and Residential Buildings

Track water consumption and optimize water resource allocation

Agricultural and Irrigation Systems

Monitor and control water flow in irrigation systems

Research and Development

Use as a precise flow measurement tool in laboratory and research applications

Pin Configuration

  • 1/8 Inch Water Flow Sensor YF-S401 Pinout Explanation
  • The 1/8 Inch Water Flow Sensor YF-S401 is a popular IoT component used to measure the flow rate of liquids. It has a simple and compact design, making it easy to integrate into various applications. The sensor has a total of 3 pins, which are explained below:
  • Pin 1: VCC (Power Supply)
  • ---------------------------
  • Function: Provides power to the sensor
  • Voltage Requirement: 5V DC ( typical operating voltage)
  • Current Consumption: Typically around 15mA (dependent on the specific application)
  • Connection: Connect to the positive terminal of a 5V power supply or a microcontroller's 5V output pin
  • Pin 2: GND (Ground)
  • --------------------
  • Function: Provides a reference ground for the sensor
  • Connection: Connect to the negative terminal of a 5V power supply or a microcontroller's GND pin
  • Pin 3: OUT (Output)
  • -------------------
  • Function: Outputs a pulse signal proportional to the flow rate of the liquid
  • Output Type: Digital pulse signal (TTL level)
  • Output Frequency: The frequency of the output pulse signal is directly proportional to the flow rate of the liquid
  • Connection: Connect to a digital input pin of a microcontroller or a counter/input capture pin to measure the pulse frequency
  • Connection Structure:
  • To connect the 1/8 Inch Water Flow Sensor YF-S401:
  • 1. Connect the VCC pin to the positive terminal of a 5V power supply or a microcontroller's 5V output pin.
  • 2. Connect the GND pin to the negative terminal of a 5V power supply or a microcontroller's GND pin.
  • 3. Connect the OUT pin to a digital input pin of a microcontroller or a counter/input capture pin.
  • Example Connection Diagram:
  • ```
  • +---------------+
  • | +5V Power |
  • | Supply |
  • +---------------+
  • |
  • |
  • v
  • +---------------+ +---------------+
  • | YF-S401 | | Microcontroller|
  • | (VCC Pin) | | (5V Output) |
  • +---------------+ +---------------+
  • |
  • |
  • v
  • +---------------+ +---------------+
  • | YF-S401 | | Microcontroller|
  • | (GND Pin) | | (GND Pin) |
  • +---------------+ +---------------+
  • |
  • |
  • v
  • +---------------+ +---------------+
  • | YF-S401 | | Microcontroller|
  • | (OUT Pin) | | (Digital Input)|
  • +---------------+ +---------------+
  • ```
  • Remember to use a suitable power supply and ensure the connections are secure and reliable to avoid any damage to the sensor or the connected devices.

Code Examples

1/8 Inch Water Flow Sensor YF-S401 Documentation
Overview
The 1/8 Inch Water Flow Sensor YF-S401 is a digital flow sensor designed to measure the flow rate of fluids, particularly water, in various applications. This sensor is ideal for monitoring water consumption, detecting leaks, and controlling fluid flow in industrial, commercial, and residential settings.
Technical Specifications
Operating voltage: 5V DC
 Current consumption: 15mA
 Flow range: 1-30 L/min
 Accuracy: 5%
 Resolution: 0.1 L/min
 Response time: 1s
 Output: Digital pulse signal
 Connector: 3-pin JST connector
Example 1: Basic Water Flow Measurement using Arduino
This example demonstrates how to use the YF-S401 sensor to measure water flow rate using an Arduino board.
Hardware Requirements
Arduino Uno or compatible board
 1/8 Inch Water Flow Sensor YF-S401
 Breadboard and jumper wires
Software Requirements
Arduino IDE (version 1.8.x or later)
Code
```c++
const int flowSensorPin = 2;  // Digital pin 2 for pulse input
volatile int pulseCount = 0;
void setup() {
  Serial.begin(9600);
  pinMode(flowSensorPin, INPUT);
  attachInterrupt(digitalPinToInterrupt(flowSensorPin), pulseCounter, RISING);
}
void loop() {
  pulseCount = 0;
  delay(1000);  // Take a 1-second sample
  detachInterrupt(digitalPinToInterrupt(flowSensorPin));
  float flowRate = (pulseCount / 7.5);  // Convert pulses to L/min
  Serial.print("Flow rate: ");
  Serial.print(flowRate, 2);
  Serial.println(" L/min");
  attachInterrupt(digitalPinToInterrupt(flowSensorPin), pulseCounter, RISING);
}
void pulseCounter() {
  pulseCount++;
}
```
Example 2: Water Leak Detection using Raspberry Pi
This example demonstrates how to use the YF-S401 sensor to detect water leaks using a Raspberry Pi.
Hardware Requirements
Raspberry Pi (any model)
 1/8 Inch Water Flow Sensor YF-S401
 Breadboard and jumper wires
Software Requirements
Raspbian OS (latest version)
 Python 3.x (built-in with Raspbian)
Code
```python
import RPi.GPIO as GPIO
import time
# Set up GPIO library
GPIO.setmode(GPIO.BCM)
# Define flow sensor pin
FLOW_SENSOR_PIN = 17
# Set up flow sensor pin as input
GPIO.setup(FLOW_SENSOR_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP)
# Set up pulse counter
pulse_count = 0
def pulse_counter(channel):
    global pulse_count
    pulse_count += 1
# Set up interrupt on rising edge
GPIO.add_event_detect(FLOW_SENSOR_PIN, GPIO.RISING, callback=pulse_counter, bouncetime=200)
while True:
    time.sleep(1)  # Take a 1-second sample
    flow_rate = pulse_count / 7.5  # Convert pulses to L/min
    pulse_count = 0
    if flow_rate > 5:  # Adjust threshold value as needed
        print("Water leak detected!")
    else:
        print("No water leak detected.")
```
Example 3: Water Flow Monitoring using ESP8266
This example demonstrates how to use the YF-S401 sensor to monitor water flow rate using an ESP8266 board.
Hardware Requirements
ESP8266 board (e.g., NodeMCU)
 1/8 Inch Water Flow Sensor YF-S401
 Breadboard and jumper wires
Software Requirements
Arduino IDE (version 1.8.x or later) with ESP8266 support
Code
```c++
#include <WiFi.h>
const int flowSensorPin = D5;  // Digital pin D5 for pulse input
volatile int pulseCount = 0;
WiFiClient client;
void setup() {
  Serial.begin(9600);
  pinMode(flowSensorPin, INPUT);
  attachInterrupt(digitalPinToInterrupt(flowSensorPin), pulseCounter, RISING);
  
  // Connect to WiFi and initialize client
  WiFi.begin("your_wifi_ssid", "your_wifi_password");
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi...");
  }
  Serial.println("Connected to WiFi");
  client.setServer("your_server_ip", 80);
}
void loop() {
  pulseCount = 0;
  delay(1000);  // Take a 1-second sample
  detachInterrupt(digitalPinToInterrupt(flowSensorPin));
  float flowRate = (pulseCount / 7.5);  // Convert pulses to L/min
  Serial.print("Flow rate: ");
  Serial.print(flowRate, 2);
  Serial.println(" L/min");
  
  // Send data to server using HTTP POST
  client.print("POST /update HTTP/1.1
");
  client.print("Host: your_server_ip
");
  client.print("Content-Type: application/x-www-form-urlencoded
");
  client.print("Content-Length: ");
  client.print( String("flow_rate=").concat(String(flowRate, 2)));
  client.print("

");
  client.stop();
  
  attachInterrupt(digitalPinToInterrupt(flowSensorPin), pulseCounter, RISING);
}
void pulseCounter() {
  pulseCount++;
}
```
These examples demonstrate the basic usage of the 1/8 Inch Water Flow Sensor YF-S401 in different contexts. You can modify the code to suit your specific requirements and integrate it with other IoT components for more complex applications.