Not Seeing what I’d expect from the Code Below.
Simply trying to display the Fan Speed from My Printer Enclosure.
The Waveform from the Fan Tach looks Ok on the Scope, sitting at 3V & 20Hz with a bit of movement.
It jumps about a bit, but became more stable when I added the Median Filter.
Then tried sliding_window… & it jumped all over the place. mostly displaying numbers in the 2000 to 4500 RPM range, while the Scope still showed a more stable 20Hz.
Throttle_Average also jumps about, but more with a +/- 150 RPM variation.
Other thing I notice is that when using Median:, the Time_out seems to be ignored.
Any Suggestions on Why this is happening when I enable some of the commented out Filters?
Note Also I’m not trying to use any of the Average Types at the Same Time.
Code as follows:-
sensor:
- platform: pulse_meter
pin: 34 # Was 23
unit_of_measurement: 'RPM'
name: 'Fan 1 RPM'
id: 'fan1_rpm'
accuracy_decimals: 0
timeout: 1s # Reset to 0 after 1 second without a pulse
filters:
- multiply: .5 # (2 pulses per Rev)
- median:
window_size: 20
send_every: 10
send_first_at: 1
# - sliding_window_moving_average:
# window_size: 15
# send_every: 15
# - throttle_average: 1s
You need pullup on your tach input. Either internal or external. Gpio34 doesn’t have internal, so use some other pin
And pulse counter is better choice.
Wait, are your trying to read the values from a PWM controlled fan from the third pin?
PWM -pulse width modulated- feel the width
Where is it getting controlled from? Ask that. It might be easier.
add a timeout filter (pick one from the examples, middle one looks like what you want).
# Example configuration entry
filters:
- timeout: 10s # sent value will be NaN
- timeout:
timeout: 10s
value: !lambda return 0;
- timeout:
timeout: 10s
value: last # sent value will be the last value received by the filter
So that should fix the issue with the initial filter disabling?
- platform: pulse_meter
pin: 34 # Was 23
unit_of_measurement: 'RPM'
name: 'Fan 1 RPM'
id: 'fan1_rpm'
accuracy_decimals: 0
timeout: 1s # Reset to 0 after 1 second without a pulse
Thanks.
Will give it a Try in 12 hours.
As is Tomorrow morning here in Aus.
That Issue is Solved.
It was the Order in Which I was Applying the Filters that was causing the Unexpected Values being Passed.
Current Code is this, including Commented out Blocks.
sensor:
- platform: pulse_meter
pin: 34 # Was 23
unit_of_measurement: 'RPM'
name: 'Fan 1 RPM'
id: 'fan1_rpm'
accuracy_decimals: 0
# internal_filter_mode: PULSE #Default is EDGE # No Improvement
# internal_filter: 2ms
timeout: 1s # Reset to 0 after 1 second without a pulse
filters:
# - throttle_average: 3s # Works Now When Above Multiply.
- sliding_window_moving_average: # Needs to be Before Multiply.
window_size: 100
send_every: 10
- multiply: .5 # (2 pulses per Rev)
- lambda: 'return 5 * round(x / 5);' # Just to Round to Nearest Value when ther is Flicker.
# - median: #Seems to Default Timeout Back to 5 Minutes
# window_size: 5
# send_every: 5
# send_first_at: 1
- timeout: # Fixes Value Not Returning to Zero with Averaging Avtive.
timeout: 1s
value: !lambda return 0;