Hall Effect Water Flow Sensor - Complete Guide
Hall Effect Water Flow Sensor | Complete Guide
Turbine-type Hall Flow Sensor · Principles · Selection · Installation · Wiring · Code · Calibration
1. Working Principle
Core structure: Plastic valve body + Turbine impeller with magnet + Hall sensor
Water flows in from the inlet, driving the turbine impeller to rotate
The magnet on the impeller rotates with the wheel, causing periodic magnetic field changes
The Hall sensor detects magnetic field changes and outputs square wave pulses (HIGH/LOW)
Pulse frequency is proportional to flow rate; total pulse count is proportional to water volume
Microcontroller (e.g., Arduino) reads pulses to calculate flow rate and volume
Key Specifications
USN-HS21TA
G1/2 interface | 5V | 600 pulses/L | Flow: 1-30L/min
2. Selection Guide
Interface Size: G1/2 (4分)
Flow Range: 1-30L/min
Voltage: DC 5V, compatible with Arduino/microcontrollers
Media: Clean cold/warm water, avoid debris
Accuracy: Typical ±3%, suitable for consumer and DIY projects
3. Installation Steps
1. Correct Direction
The sensor housing has a water flow arrow. It must match the actual flow direction or no signal will be output.
2. Pipe Installation
Connect in series at the water inlet, horizontal installation is best
Leave 5~10cm straight pipe before and after to reduce turbulence
Use Teflon tape for sealing, do not over-tighten
3. Environment
Keep away from strong magnetic fields
Operating temp: 0~60°C, avoid prolonged high temperature
4. Hardware Wiring
3-wire sensor (Red/Black/Yellow), simple wiring, no extra components needed
| Sensor Pin | Wire Color | Arduino Pin | Description |
|---|---|---|---|
| VCC | Red | 5V | Power positive |
| GND | Black | GND | Power ground |
| SIG | Yellow | D2 | Pulse output (External interrupt) |
Note: Signal pin must connect to interrupt pin to avoid missing pulses
5. Code Implementation
Function: Output instantaneous flow (L/min) and cumulative volume (L) every second
// Define pins and parameters
#define sensorPin 2 // Signal pin connected to D2
#define pulsePerLiter 600 // USN-HS21TA: 600 pulses/L
volatile unsigned long pulseCount = 0;
unsigned long oldTime = 0;
float flowRate = 0;
float totalVolume = 0;
void setup() {
pinMode(sensorPin, INPUT);
Serial.begin(9600);
attachInterrupt(digitalPinToInterrupt(sensorPin), pulseCounter, FALLING);
}
void loop() {
if (millis() - oldTime > 1000) {
detachInterrupt(digitalPinToInterrupt(sensorPin));
flowRate = ((float)pulseCount / pulsePerLiter) * 60.0;
totalVolume += (float)pulseCount / pulsePerLiter;
Serial.print("Flow: ");
Serial.print(flowRate, 2);
Serial.print(" L/min | Volume: ");
Serial.print(totalVolume, 2);
Serial.println(" L");
pulseCount = 0;
oldTime = millis();
attachInterrupt(digitalPinToInterrupt(sensorPin), pulseCounter, FALLING);
}
}
void pulseCounter() {
pulseCount++;
}6. Calibration & Troubleshooting
Calibration Method
Prepare a container with known volume (e.g., 1L graduated cylinder)
Run water and record serial output, compare with actual volume
Fine-tune pulsePerLiter until error < 3%
Troubleshooting
No pulse signal (flow = 0):
Check wiring: Red=5V, Black=GND, Yellow=Signal
Verify water flow direction arrow
Clean impeller debris
Verify 5V power supply
Flow fluctuating/inaccurate:
Add straight pipe sections, install horizontally
Avoid strong magnetic interference
Verify pulse coefficient
7. Applications
Water heater/coffee machine flow detection
Smart irrigation, auto valve shutoff
Water circulation monitoring, measured dispensing
Summary
Hall Effect Water Flow Sensor Key Points: Correct direction, proper wiring, matching pulse coefficient
Follow this guide and beginners can quickly get started with accurate flow and volume measurement.