Encoder on MCP23017 not able to read

Hello, I'm trying to read anything out of my MCP23017.
I'm struggling to get it to work however.
I've tried to copy this Schematics and code from this github (I'm using the Polling example):

Uploading the code worked fine.
Let me show you an Image of the circuit:

I've also tried different things. Like adding resistors from the MCP23017 pins: SDA to the 5V and from the SCL to the 5V.
As well as connecting those pins to the SDA and SCL pins on the arduino.

Nothing seems to work and i get no messages other than the initial 'MCP23007 Polling Test" print. I'm out of options. Does anyone have any idea where I'm mistaken here?
Also I'm wondering if the MCP23017 chip is not functioning, I've ordered them cheap from Aliexpress.

I am glad for any help or suggestions. Thank you very much!

The Github links point out into a jungle. Please be more precise.
Please post schematics. The pictures might interest a murder criminal detective but takes too much time to analyze for most helpers.

Your failed attemtpts are of no help.

That's a usual statement that's of no help.

Schematics...., please. A link to the datasheet of the MCP23017 would make more helpers respond.

Hello, thanks for the response!
Its my first post in the forums, let me add some sources!

The Circuit on the photograph is a implementation of this schematics:

The MCP23017 can be viewed here:

I meant nothing seemed to work, even when trying different setup. Since My photograph showed a connection to the A4/A5 pin instead to the SCL SDA pin. but neither case worked out.

edit:

Specifically I'm using the code example here:

Please post schematics. Fritzing picture is not schematics.

The Datasheet can be found here:

You have no pull up resistors on the I2C lines.
You have no pull up resistors on the INTA and INTB pins.
The reset pin is not connected to anything, it needs to be connected either to a pin or the reset line on the Arduino.
You have no supply decoupling capacitor on that chip.

A4 and A5 are exactly the same as the SCL SDA pins. They are wired to the same place in the Arduino.

1 Like

Connect 10K pullup resistors between SCL and 5V and SDA and 5V
Then run the I2C_scanner sketch.
It is found on the menu under Files->Examples->Wire
You may have to scroll up/down to find Wire
It should find a device at 0x20

1 Like

Thanks!
After making those changes to the previous circuit:

  1. adding 10K resistors from:
  • SDA to 5V
  • SCL to 5V
  • INTA to 5V
  1. As well as changed the Reset Pin from:
  • Reset (MCP23017) to 5V (Arduino) -> Reset (MCP23017) to Reset (Arduino)

It started to work printing the clockwise or counter clockwise turning of the rotary encoder.

I am confused, why the schematics on the Github recommend a different circuit but seemed to work on their side. But I'm glad the prior described adjustments made it work. I haven't yet added a supply decoupling capacitor. Is it necessary? What capacity do I use? And where exactly in the Circuit would i Connect it?

Anyhow, thank you very much for the responses!

Hello, also thanks for this recommendation!
I've used this Example while adjusting the circuit and observe the "I2C device found at address 0x20 !" message in the Serial Monitor.
It certainly helped!

Great you got it working.

Probably because they never actually tried them. There are a lot of software people out there who are totally ignorant about hardware. Or maybe they tried them on a simulator not knowing simulators do not do a good job of simulating actual hardware.

Decoupling capacitors are an important part about making a circuit stable.
This tutorial tells you why:-
Decoupling tutorial

1 Like

Thanks for the Decoupling Tutorial!
I dont need any help currently but I just wanted finalize the solution and also mention:

It's been a blast reading the de-coupling tutorial and actually when I tried to expand the circuit and stumbled upon this problem! It was nice to understand why to also add a smaller capacitors basically in parallel next to each IC even though it is actually just parallel to a bigger one.

So one encoder was (kind of) working with my previous circuit. But now with the capacitors (which I quickly recycled from old electronics because otherwise it wasn't available to buy on a Sunday) I was able to expand it.
For documentation purposes I upload an Image with a new circuit, in case anyone else stumbles upon this thread and has the same problem.

So yeah, I've added a bigger capacitor with 47 uF and smaller capacitors with 0.022uF closer to the ICs. Basically they are places between +5V and GND. But as already mentioned the 0.022 uF are closer to the V_DD and V_SS.

My personal next step is to add 64 Encoders to this circuit.
Unless I stumble on a problem on the way, this thread is likely to be finished.

Thank you very much for the help!

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.