The Water Flow Rate Sensor YF-S401 by Sea is a compact and versatile sensor designed to measure the flow rate of water. It is commonly used in applications such as irrigation systems, water dispensers, and in any system where monitoring water consumption or flow is necessary. The sensor operates by detecting the movement of water through a pipe and converting it into a measurable signal.
Pin Number | Description | Notes |
---|---|---|
1 | GND (Ground) | Connect to system ground |
2 | VCC (Power Supply) | 5-18V DC |
3 | Signal Output | Outputs pulse signal |
// Define the connection pin and the pulse count
const int sensorPin = 2; // Digital pin connected to the sensor's output
volatile int pulseCount; // Volatile because it is in an interrupt context
// Interrupt Service Routine for the flow sensor
void flowRatePulse() {
pulseCount++;
}
void setup() {
Serial.begin(9600);
pinMode(sensorPin, INPUT);
attachInterrupt(digitalPinToInterrupt(sensorPin), flowRatePulse, RISING); // Attach the interrupt
}
void loop() {
pulseCount = 0; // Reset the pulse counter
interrupts(); // Enable interrupts
delay(1000); // Wait 1 second
noInterrupts(); // Disable interrupts
// Calculate the flow rate in L/min
// Sensor frequency (Hz) = 7.5 * Q (L/min)
// Pulse frequency (Hz) = 7.5 * flow rate in L/min
// Note: The flow rate unit from this calculation is in L/min
float flowRate = pulseCount / 7.5;
Serial.print("Flow rate: ");
Serial.print(flowRate);
Serial.println(" L/min");
}
Q: Can the sensor be used with hot water? A: The sensor can operate within a temperature range of -25 to +80°C. Ensure the water temperature does not exceed this range.
Q: How can I calibrate the sensor for accurate readings? A: Calibration involves comparing the sensor output with a known flow rate. Adjust the calculation in the code accordingly to match the known flow rate.
Q: Is the sensor waterproof? A: The sensor is designed to measure water flow within its body but is not rated for submersion or exposure to moisture outside its intended flow path.
Q: What is the lifespan of the sensor? A: The lifespan depends on usage conditions but is generally expected to be long when used within the specified parameters.
For further assistance, please contact the manufacturer or refer to the official datasheet for the YF-S401 Water Flow Rate Sensor.