The sensor comes with three wires:
1. Red (5-24VDC power) 2. Black (ground) 3. Yellow (Hall effect pulse output)
The water flow rate can be calculated by counting the pulses from the output of the sensor. Each pulse is approximately 2.25 milliliters. This Sensor is cheaper and best but not the accurate one as flow rate/volume varies a bit depending on the flow rate, fluid pressure, and sensor orientation. To get better precision of more than 10%, a lot of calibration is required. You can make a basic IoT Based Water Flow Meter using this Sensor. The pulse signal is a simple square wave so its quite easy to log and convert into liters per minute using the following formula.
ESP8266 & Water Flow Sensor
Now let us interface YF-S201 Hall-Effect Water Flow Sensor with Nodemcu ESP8266 & OLED Display. The OLED Display will show Water Flow Rate & Total Volume of Water passed through the pipe. The same Flow Rate & Volume data can be sent to Thingspeak Server after an interval of 15 seconds regularly. You can switch to Blynk Application if you want immediate data. Similarly using MQTT Protocol better wireless communication can be achieved.
we can use for NodeMCU & Arduino ---> D2 or D4 or any PIN ...
Mathematical Calculation to Measure Flow Rate & Volume
We have determined flow rate by a change in velocity of the water. The water velocity depends on the pressure that forces the through pipelines. The cross-sectional area of the pipe is known and remains constant, thus we calculate the average velocity that indicates the flow rate. Let us consider Q is the flow rate/total flow of water through the pipe, V is the average velocity & A is the cross-sectional area of the pipe. In such a case the basis relationship for determining the liquid’s flow rate in such cases is Q=VxA Sensor Frequency (Hz) = 7.5 * Q (Liters/min) Litres = Q * time elapsed (seconds) / 60 (seconds/minute) Litres = (Frequency (Pulses/second) / 7.5) * time elapsed (seconds) / 60 Litres = Pulses / (7.5 * 60)
The VCC (Red Wire) and GND (Black Wire) pins of flow sensors are connected to 5V and GND pins of NodeMCU while the Signal pin (Yellow Wire) is connected to D4 pin of NodeMCU.
we don\'t need library