ESPHome - Rotary encoder RPM in yaml

Good Morning,

I’m fairly new to ESPHome and yaml and I’m wondering if someone could please help me with an easy way to convert the running pulses from a 360ppr rotary encoder into RPM.

In Arduino IDE I’m able to write it using an interrupt to pull the old value and then a second later take another value from this running count and then divide 360 because the PPR is 360 and then multiply by 60 to get the RPM.

So basically ((NewCount - OldCount)/360*60)

My issue is that I am not very jacked up on ESPHome and still learning. I’ve got it to the point where I’m counting each pulse from the encoder, but I have no idea how to take a value from it in ESPHome and have it accurate to 1s?

Please could you advise me or show me a method.

This is my first post so I’m unsure as to how to attached my code like everyone else does :slight_smile:


Welcome to HA and ESPHome.

Have you looked at the Pulse Meter component? It returns a time between pulses, if you know the number of pulses per revolution you could then calculate the RPM.

As far as posting code goes the cardinal rule is to use preformatted text tags (they are shown as </> on the posting toolbar). Have a read of the link below especially the bit about formatting in point 11.

1 Like

Thank you so much, Whilst I didn’t have success with the Pulse Meter Sensor, it led me to the Pulse Counter Sensor and that did the trick for me :slight_smile: