Encoders on Waveshare MCP23017 don't work

I am trying to use a Waveshare MCP23017 board for the encoders and I can’t get it to work.
In its initial state, the boards adress was 27 and Zynthian didn’t recognise the board. I shorted the adress jumpers to ground and that moved it to 20 and Zynthian now sees it as a MCP23017, but the encoders still don’t work. I have also modified the board to bring it as close to the zynthian mcp AllinOneSchematic. The encoders are KY-040 with the resistors remoevd.
Here are some pictures of the encoder config and the modified waveshare board schematic. Also, I am using the latest zynthian official image.
Anybody have any idea what I’m doing wrong?

Hi @Kovu welcome on board,

I do not know these waveshare boards and how you have physically done your connections, but they are two headers 6 (labelled as H3 and H4) and one is with pull up resistor on I2C line while the other is not.

Hello and thank you for the welcome!
H3 and H4 have the same connections in them.
I have also tried removing the pullup resistors and it made no difference.
Here are a couple of pictures

Your issue comes from the type of encoders boards you’re using.
Workaround here:

I have removed all resistors from the encoders and connected the GND on each encoder to a separate GND on the PI I/O ( pind 6,9,14 and 20)
I’ve just carried out a test with the unmodified encoder I have ( purchased a set of 5 ) and it will not work with the pull up resistors in place.

I have the encoders wired the same way he has, other than the separate ground on the PI I/O. All my encoders have the resistors removed and no +5v connected.
The difference is he got some sort of response from the encoders even when wired wrong. I get nothing, regardless of how I turn the encoders or push the switch. This is what makes me think it’s a software issue. I even tried a new MCP board just to make sure I didn’t break the first one, same result: absolutely nothing.
Is there some sort of library I need to install or should it work with a vanilla instalation of zynthian?

The MCP23017 is communicated with via I2C. Zynthian provides the device driver to implement this communication.

Zynthian needs to be configured to know the MCP23017’s I2C address. By default this is 0x20.

Zynthian needs to be configured to know the pins to which each encoder / switch is connected. Zynthian uses an extended GPI range to address these pins starting at 100 hence the first MCP23017 GPI is pin 100, the second is pin 101, etc. This is configured in Wiring page of webconf. The Zynthian may need to be restarted after asserting these changes in webconf.

Zynthian needs to be configured to know the pins to which the interrupts are connected. By default this is WiPi-GPIO2 / BCM-GPIO27 / 40-way header pin 13 and WiPi-GPIO7 / BCM-GPIO4 / 40-way header pin 7.

I wonder if you have connected up all the correct pins including the interrupts?

The all-in-one does not have pull-up resistors on the I2C lines. Maybe that might have an impact.

I got it to work but it was none of the above, I didn’t change anything in the wiring.
What I did was an update, altho it didn’t install anything new, and then I selected a random Zynaptik config and they started working. They still worked even after I removed the Zynaptik config so it looks like it might have been a glitch.
I will flash a card with a clean image and try to replicate the results so others who run into this issue will know what to do.

Definitely perform a Zynthian Update from the UI admin menu or webconf after building a new image. Updates are fixing issues all the time so you are likely to have some kind of issue without doing so.

Actually do it twice. This has been required in the past.