Encoders on MCP23017

Nice work @beckdac.
I only wonder how this fits with the big picture of your USB connected switches, @jofemodo.
Wouldn’t it be better to use this controller with a USB Interface, so that you can chain them?
Tell me, if I should integrate his wiring as selectable option in the webconf.

Freundliche regards, :slight_smile:

Quick note: under this setup, an encoder’s A and B pins must be on the same MCP23017 bank.

@mheidt, I have an external controller based on Teensy 3.2 that has 8 encoders, 8 buttons and 8 air guitar strings. Is that what you are referring to? The schematic for that is here:

Guess, it should be possible to mix rotary with normal push pads as well.
Then we need a dynamic configuration and new features like midi/audio file playback and map those to the buttons.

Hi @beckdac

In your schematic pins 19 and 20 (INTA and INTB) are the GPIO ports 25 and 26 connected?

I’m working on a single board for my Zynthian with all midi connections and encoders too.

Congrats for your work! Here in Brazil I can not find the MCP23008, I will try to use the MCP23017 too!

Regards, Rod.

They are WiringPi ports 27 and 25. WiringPi has its own “portable” numbering. This pinout chart shows how to map the the WiringPi to the recent GPIO pin header in parens next to the BCM pin #:

1 Like

Another quick note. I included 4.7k pullups in my original prototype and it works fine. However, the Raspberry Pi 3 has 1.8k pullups on those lines so in practice on my prototype the final pullup resistance is 1.3k which is above the minimum for fast mode so there is no problem with the rise time. When I build another, I will leave off the external pullups. I have removed them from the schematic.

1 Like

Hi @beckdac!

Finally i had some time for testing the new “All-In-One” PCB, that includes the MCP23017 for the encoders+swithes and MIDI IN-OUT-THRU based in the @Imager’s circuit, using H1L11 optocouplers.

The controllers part works like a charm with your new code. I didn’t need to change a single line. You made a very good work, man!! Thanks a lot!

FYI, i’m testing without external pull-ups, and using the Zynthian Controller PCBs with “capacitor-to-ground” for debouncing: 100nF for switches and 10nF for encoder pins. This is really simple and works quite well. The software debouncer almost don’t need to work.

I hope to merge your changes into the master branch ASAP, so please, make a “pull request”.

In the other hand, i made a stupid error in the PCB design and MIDI-OUT & THRU are not working. You can use it to fry an egg, but not to do MIDI stuff with it, so i’ve removed the optocoupler and fixed the PCB. Now i’m awaiting for the new ones to arrive … :wink:

Super Regards!


Can we still use different kind of displays?
Having the waveshare32 and it’s special wiring in mind.

Of course! The main reason to move the controllers to a GPIO expander is easing the configuration of hardware devices like displays and soundcards by avoiding “pin collisions”.

The new All-In-One circuit only uses I2C and the GPIO 25 & 27 (pin 35 & 36) for interrupts. This 2 GPIO ports are rarely used by any device. If you know some device using it, or you think there is a better choice, speak now, please!!!, before i order a few hundred of PCBs! :wink:


So that’s 2 Pins for 12C and GPIO 25 & 27 plus +V ( 3.3V or 5V? or both ) and ground(s)

Anyone any idea how far that could be run before you need to start buffering it . . . ?

I’d like to break out the encoders into a separate enclosure. . .

Well just cos really.

HI @wyleu!

I think it should be perfectly possible to have a few meters. it depends of I2C frequency and cable capacitance. If needed, you can change the I2C frequency tweaking the config.txt, like that:


Just try and give feedback :wink:


I used i2c connection up to 2 meters, and never had problems.
But, as @jofemodo said, you can lower data rate if you have errors.

That sounds about right for what I’m invisaging…

Have we any idea when the new encoder board will be available and what the price might be?

1 Like

all in one pcb use H11L1 optocoupler IC can use 6n138 its same

I have build all Indonesian one module but no work help me please


Bu of no connect to all on one module with 7 icnh waveshare lcd itu work fine

  1. Visual Inspection & Plug Socket orientation check :smiley:
  2. Your All-in-One board stops a working machine?
  3. Does you pi die (no leds) when you connect All-In-One board?
    If so you have a Power Supply short on All-in-One.
  4. Can you measure voltages? Check (using schematic …) Check PSU pins on All-In_One board.

its work fine but add all in one module with rotarry switct encoder single controller

Continuing the discussion from Encoders on MCP23017:


What is exactly your layout configuration? If you disconnect the All-In-One circuit and configure “Dummy” wiring layout … does it work OK?

Have you tried to test your encoders from the command line?


You also can check if the MCP23017 is “on-line” for the RBPi. Just run this command:

gpio i2c

The default address of the MCP23017 GPIO expander is 0x20 :wink: