igorantolic / ai-esp32-rotary-encoder

Easy implement rotary encoder to your application using microcontroler like ESP32
GNU General Public License v2.0
284 stars 70 forks source link

Won't work with optical encoder #47

Closed kxkayser closed 1 year ago

kxkayser commented 1 year ago

Hi. Have the function working well with simple mechanical encoder. Want to switch to optical encoder described here: https://smile.amazon.com/dp/B07MX1SYXB?psc=1&ref=ppx_yo2ov_dt_b_product_details. This encoder apparently is looking for high logic on the A and B pins and takes them low when sending pulses and requires a minimum of 5v cc. I consequently pulled up the A & B pins in my ESP32 sketch. I have the vcc connected to my Vin pin which seems to be working. I wrote a test sketch and I can trigger an interrupt if the condition is FALLING but not if it is LOW. Can't get your function to work reliable. Any suggestions? Thanks.

igorantolic commented 1 year ago

replacing in code pullup <-> pulldown doesn't help?

kxkayser commented 1 year ago

Thanks Igor. I used pullup. I think the problem was that I am powering the Encoder from the Vin pin on the ESP32. The encoder is rated at 5-24volts and I think the Vin under load was not providing enough voltage. When powering from an external supply, it seems to work fine. I will have to find an alternate way of supplying Vcc to the encoder as this is a portable, battery powered application. Thanks again