Pulse counter with odd pulse signal

I have a flow meter (hall effect) that has a very odd pulse. Inside the flow meter there are 2 magnets which I believe contribute to this. The issue is that the reported value is highly variable, like around 10%.
I switched from an ESP8266 to a ESP32 which didn’t help. I confirmed with a pulse generator (sine or square wave) and I get great results (<0.1% variability) I’ve tried many options (rising vs. falling) to get it to work without any success. I believe I need to use some circuit to modify the signal like a comparator with an op-amp. Anyone run into this or have a circuit suggestion? Below is what the signal looks like

So I figured out a solution and thought I would share it here. I used just a simple RC (resistor-capacitor) circuit/filter. https://en.wikipedia.org/wiki/File:RC_Series_Filter_(with_V%26I_Labels).svg

Using the formula f = 1/(2piRC). The frequency this flow meter runs at is around 2Hz so I’m using a 10k and 4.7uF capacitor. Here is the filtered signal

1 Like