I’m pretty new with esphome, I want to make a small weather station with the weather kit from sparkfun ad both the rain gauge and the anemometer send pulses to keep track of precipitation and wind speed (ex. Rain Gauge: 1 pulse = 0.254mm Anemometer: 1 pulse per second = 2.4km/h).
Now I found the pulse_counter with the “Total” attribute which should give me the total pulses, so I built a small circuit on a breadboard with a button instead of the reed switches used by the rain gauge and the anemometer to test it out.
sensor:
- platform: pulse_counter
pin:
number: 21
inverted: true
mode:
input: true
pullup: true
name: 'Pulsazioni'
count_mode:
rising_edge: INCREMENT
falling_edge: DISABLE
update_interval: 10s
use_pcnt: False
internal_filter: 50us
total:
name: 'Pulsazioni Totali'
This is the code, as you can see I tried also to disable the esp32 dedicated hardware to increase the internal filter but the issue it’s still there. The issue is if I click (whether I do it quickly or slowly) the button for example 15 times the registered pulsed could go from the exact value to even 8-12 pulses more, so I could even get a total of 27 clicks.
The only difference I saw was when I set the internal filter value to 1ms which caused to count less clicks than the actual made (ex. 10 click made and 6 clicks counted)
The pulse_counter documentations also says on the esp32 it should be highly accurate, so I suppose I’m doing something wrong but can’t figure out what.