Sorry i forgot to mention i tested this with Internal pullup on Pin 12 and with internal and external pullup 10k together on pin 22.
Leads to same result
You might want to present your circuit. What is giving the pulses? How long wiring etc. 1K pullups behave better in noisy environment than 10k or 40k.
You can also try longer filter and different internal_filter_mode.
So the question is: “is the counter messing up or is the signal incorrect?”
I have no idea what this means.
If I was trying to solve this problem (and I have done that for my gas meter, that has a reed switch). I would be looking at the actual signal that is coming in at the esp32. A standard GPIO has very low noise immunity, i.e. it is very sensitive to noise. It is likely that your wires to the meter are longer than a meter and possibly ten meters or more. At that length a standard GPIO is pretty much a bad idea (that sometimes works okay).
The key point is that you actually need to have a decent amount of current going through the switch, so you need a very strong pull up (as @Karosm suggested 1K or even half that). You also need the capacitator.
You may also need to limit how quickly the counter can count.
Back when I did this for my meter with Tasmota I couldn’t get its counter to work well enough, so I wrote some custom code to check the value every 500ms and then count the transitions. That worked pretty well.
I currently have it running with a newer version of Tasmota using scripting and 542ms debounce. I disconnected the reed switch (since it wasn’t working) and am using a magnetometer for the reading. The pulse counter still gets some extra pulses (0 to 10 a day), so my HW/SW combination is still not quite good enough.
It’s kind of tricky to estimate the pulse length with these kind of setups. We know that the pulse interval is >10s, but I have not really an idea about the range of pulse length if OP doesn’t measure it.
Anyway, the graph shows that there are some serious interferences or something wrong with the whole setup.
It is likely a gas or water meter. My gas meter closes the switch for about 10-20% of lowest digit’s travel (comes on at about 0 and stays closed till about 1 or 2). Depending on gas flow this means seconds to hours.
Since they work magnetically most meters will have similar behavior. Even with my 542 ms denounce it isn’t enough. This is likely because the denounce is implemented as: count the interrupt and if you get another interrupt before the debounce timer expires do not count them. This gives faster response than: when you get the interrupt, set a timer to check the input after it expires and only if it is still active count the pulse. The later method can still over count, but it is less likely.
I would stick an oscilloscope on the wire and see what is there. I suspect it is not pretty. At some point I will put an optoisolator on mine. That will require the noise to supply several mA of current to get the GPIO to count. If you have that much noise you need to figure out what is causing it and eliminate that problem first.