『Esp32 Water Flow Meter Integration: Coding a Digital Pulse Sensor to Web Server』Related information(flow rotameter|digital flow meter|balo meter|hydraulic flow meter|volumetric meter|positive displacement meter|pitot tube flow meter|displacement meter|cfm meter|variable area flow meter|inline flow meter|differential pressure flow meter|calibrated flow meter|velocity meter|paddle wheel flow meter|oval gear flow meter|anemometer hvac|multiphase flow meter|doppler flow meter|thorpe tube flowmeter|heat flow meter)

ESP32 Water Flow Meter Integration: Coding a Digital Pulse Sensor to Web Server
Quick Answer: You can connect an industrial flow meter pulse output to an ESP32 using an optocoupler or a 10 kΩ pull up resistor. Count rising edges with an interrupt routine in Arduino code, convert pulse frequency with the meter K factor, and send the data to a web server over WiFi every 5 to 10 seconds. Silver Automation Instruments supplies flow meters with pulse outputs that fit this exact wiring and software pattern.
What You Need for the Integration
Most engineers skip the analog side and use the pulse output from a flow meter. The pulse output is easier to read on a microcontroller than a 4-20 mA signal. You need an ESP32 board, a flow meter with pulse output, a 5 V or 24 V DC power supply, and a way to buffer the pulse signal. For industrial flow meters with 24 V open collector NPN outputs, use a PC817 optocoupler or a resistor divider. For a bench test with a 5 V meter, a 10 kΩ pull up resistor to 3.3 V works fine.
Pulse Output Wiring on ESP32
Industrial flow meters often have an open collector NPN pulse output. The signal swings from 24 V down to 0 V in many 24 V DC powered meters. Do not connect this directly to ESP32 pins. ESP32 input pins are not 5 V tolerant and will fail at 24 V. Use an optocoupler or a simple resistor divider if the pulse source is 5 V.
For bench tests with a Silver Instruments turbine flow meter on 5 V, connect the pulse wire to a 10 kΩ pull up resistor tied to 3.3 V. Then connect the same node to GPIO 34. The pulse signal must not exceed 3.3 V. Use GPIO 34 or GPIO 35 if you want input only pins. Both work well for pulse counting.
Code Structure Without Fluff
Set the pulse pin as INPUT_PULLUP in Arduino code. Attach an interrupt on the rising edge. Keep the interrupt service routine very short. Increment a volatile unsigned int variable inside the ISR. Do not send web requests from inside the ISR. In the loop function, read the count every 1000 ms, subtract the previous count, and divide by the K factor to get flow rate in litres per second.
Use attachInterrupt(digitalPinToInterrupt(flowPin), pulseISR, RISING) and keep the ISR free of delays. In the main loop, build a small JSON string with double quotes. Use WiFiClient to send an HTTP POST to your web server every 10 seconds. Silver Instruments customers often send data to a local SCADA or a small Laravel API. Keep the JSON keys short: flow_lpm, total_l, meter_sn, timestamp. That reduces RAM use on the ESP32.
K Factor and Flow Rate Formula
You must know the K factor from the flow meter calibration sheet. A K factor of 10 pulses per litre means one pulse equals 0.1 L. A K factor of 450 pulses per litre means one pulse equals about 0.0022 L. Pulse frequency in Hz divided by K factor gives litres per second. Multiply by 60 for litres per minute.
Silver Instruments electromagnetic flow meters with pulse output can be configured. For a DN50 meter on a wastewater line in Malaysia, set the pulse output to 1 L per pulse. For a DN15 oval gear flow meter dosing chemicals, set the pulse output to 0.01 L per pulse. The ESP32 code uses the same counting logic either way.
Common Pitfalls on Customer Sites
We have seen this on customer sites many times. Long pulse wires pick up AC noise from VFD pumps. Use screened cable and keep the pulse cable away from motor cables. Add a 100 nF capacitor at the ESP32 input if the pulse edges are sharp and cause multiple i

A paint manufacturer in Southeast Asia had random pulse counts because an ungrounded 24 V power supply floated the pulse reference. The fix was a common ground between the flow meter, the power supply, and the ESP32. After that the count matched the batch volume within 0.5%.
Web Server Data Fields That Matter
Send more than just flow rate. Include total volume, temperature, pipe DN, and meter serial number. If you use a pressure transmitter on the same skid, add pressure in bar. A 4-20 mA HART input can go to a separate ADC channel later. Keep the ESP32 firmware focused on pulse counting first. The web server can scale and alarm on the values.
Which Flow Meter Works with ESP32
Digital pulse outputs are common on Silver Automation Instruments electromagnetic flow meters, turbine flow meters, oval gear flow meters, and vortex flow meters. Thermal mass flow meters can also be ordered with pulse output, but they need more setup for low flow cut off. Coriolis mass flow meters from Silver Instruments can also send a pulse output, but they cost more and are better for mass flow like kg/h on chemical injection lines.
For water and wastewater, choose an electromagnetic flow meter with pulse output, 316L electrodes, PTFE liner, and IP67 housing. For diesel or light oil monitoring, choose an oval gear flow meter with a reed switch pulse output. For a cooling water line in Indonesia, we recommend a Silver Instruments electromagnetic flow meter with pulse output, DN25, 0.5% accuracy, PTFE liner, 316L electrodes, and 4-20 mA HART as a backup signal.
Frequently Asked Questions
Which ESP32 pin is best for a flow meter pulse sensor? Use GPIO 34 or GPIO 35. Both are input only and work well with RISING edge interrupts. You can use other pins if you need extra ADC or I2C lines. Keep the pulse wire short.
Can I connect a 24 V flow meter pulse output directly to the ESP32? No. The ESP32 pin will fail at 24 V. Use an optocoupler or a resistor divider. For open collector NPN outputs, a 10 kΩ pull up to 3.3 V is safe when the meter power supply shares a ground with the ESP32.
What K factor should I use for an industrial flow meter? Read the calibration sheet from the flow meter manufacturer. Silver Automation Instruments includes a K factor or pulse per litre setting with every pulse output meter. If the value is lost, send us the meter serial number and the fluid type. We can check the factory data.
How do I send flow data from the ESP32 to a web server? Use WiFiClient to POST a small JSON payload every 5 to 10 seconds. Keep the keys short. Flow rate in litres per minute, total volume in litres, and meter serial number are enough for most sites. Use HTTPS only if the ESP32 free RAM and CPU allow it.
What flow meter from Silver Instruments works with ESP32? Most electromagnetic flow meters, turbine flow meters, oval gear flow meters, and vortex flow meters can be ordered with pulse output. Tell us the pipe size, fluid, pressure in bar, temperature in °C, and flow range. We will suggest one meter with the correct K factor and liners.
Send Your Flow Range for a Fast Quote
Send us your pressure in bar, temperature in °C, pipe size DN, and flow range. Silver Automation Instruments will recommend a pulse output flow meter that works with your ESP32 web server setup. Tel: +86-25-68650347, WhatsApp: +86-25-52155837, WeChat: +86 15365082610. Website: flow-meter.com.au

Hot Blog
Related AD
