This is an old revision of the document!
Table of Contents
ESP32 - Rotary Encoder
How to reliably read rotary encoder on ESP32?
Background
For usage on my ESP32 projects, I ordered several rotary encoders from Ali Express. It appeared that all of these gave many erratic and unreliable readings. Indicating CW when turning CWW and visa versa. Approximately out out the 20-30 readings was erroneous. Initially I assumed contact bouncing, but the problem persisted after implementing an anti-bounce filter in the software. On a Raspberry this problem does not exist, so it seems that the ESP32 does not work well with this type of rotary encoders. This page describes both cause and solution for this problem.
Problem cause
It appears that the encoders I bought have RC filters on their output connections. Apparently, with the intention to eliminate contact bounce. However, side effect of this is that the rise and decay times of the rotary pulses do not have sharp edges, but curved edges.
Hardware Modifications
Method 1
Method 2
Links
- Unordered List Itemwww.allaboutcircuits.com



