earthdog
Posts: 15
Joined: Sat Oct 10, 2015 9:56 am

Rotary encoder overlay - cant use the switch

Sun May 09, 2021 5:40 am

I have a rotary encoder setup as device in config.txt:

Code: Select all

dtoverlay=rotary-encoder,pin_a=18,pin_b=17,relative_axis=1,steps-per-period=1
The knob works ok with evtest and python programs, but i cant get the switch to work. Is it supposed to work or not?

User avatar
thagrol
Posts: 4941
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Rotary encoder overlay - cant use the switch

Sun May 09, 2021 12:24 pm

Judging by the docs, the encoder overlay doesn't support a button/switch pin.

You could always add the gpio-key overlay for the switch (see /boot/overlays/README)
I'm a volunteer. Take me for granted or abuse my support and I will walk away

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 3881
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Rotary encoder overlay - cant use the switch

Mon May 10, 2021 7:54 am

I'm assuming the button has a GPIO of its own? Yes - gpio-key is probably the way to go.

Return to “Device Tree”