Water flow Sensor Calibration using ESP 8266 | NodeMCU
Water flow sensor interfacing with ESP 8266
Water flow sensor (YF-S402B) is used in applications where measurement of quantity of liquid dispensed is needed. It can operate at a wide voltage ranges 3.5V to 24V dc making it a deal choice to work with micro controllers.
All the enthusiasts, please keep this in your collection if you work with fluids and need measurement. This sensor has to be placed horizontally as position, plumbing, pipes used can effect the flow sensor output. Do calibrate the sensor after plumbing is complete and sensor is fixed in final position.
In this tutorial, we will use YF-S402B sensor and interface it with ESP 8266.
Parts Needed
1. Water flow sensor (YF -S402B used in this tutorial, detailed video of this sensor can be found here.)
2. Submersible 6V water DC pump
3. NodeMCU
4. RO pipe and connectors
Connections
NodeMCU D5 - Yellow Wire of Sensor
NodeMCU 3V - Red wire of Sensor
NodeMCU GND - Black wire of sensor
Code
int pulse = 0; void ICACHE_RAM_ATTR increase() { pulse++; Serial.print("Pulse is at "); Serial.println(pulse); } void setup() { pinMode(D5, INPUT); Serial.begin(115200); attachInterrupt(digitalPinToInterrupt(D5), increase, RISING); } void loop() { // ESP 8266 Example for Water sensor calibration }
We will be using digital pin D5 for input and attach to an interrupt handler.
In this case when ever a signal is detected by Hall sensor the pulse is sent to D5 and rising edge will invoke increase function.
We have a counter in the function which determines the pulses received so far.
Once required water is flowed through flow sensor, measure the water using a measuring jar and you can find the precision of the sensor using below formula.
Pulse precision = Total Volume of liquid measured after transfer / pulse counter value
To get accurate results take the readings 4 to 5 times and take an average of the values.
In above example, 700 ml of water is dispensed at 1949 counter value at 0.35 ml per pulse.
Comments
Post a Comment