I bought a MCP23017 and doing some small test with it. I've made a simple Python script to make read_out of pin state. Can anyove explain to me, why i'm loosing a bit when GPIO_A7 is triggered? I've got 8 bit readout and all input changers state from 1 to 0 except GPIO_A7 so it looks like this:

GPIO_A0 = 11111110, GPIO_A1 = 11111101 But when hitting GPIO_A7 = 1111111

So i've only get 7 bit and not 8?

Hope for some help. :-)

    #!/usr/bin/env python
    # Input / output MCP23017

    import smbus
    import sys
    import time

     bus = smbus.SMBus(1)
     once = False

     def start_up(once):
         if once != True:
         bus.write_byte_data(0x22, 0x00, 0xFF) # set input bank a
         bus.write_byte_data(0x22, 0x01, 0xFF) # set input bank b
         bus.write_byte_data(0x22, 0x0C, 0xFF) # set pull-up resistor
         bus.write_byte_data(0x22, 0x0D, 0xFF) # set pull-up resister
         once = True
    return once

    def read_data(bank):
        if bank == 0:
            state = bus.read_byte_data(0x22, 0x12)
         return state

    def main():
            while True:
            state = read_data(0)
        print bin(state)

    if __name__ == "__main__":

I haven't looked too carefully at your question but it seems to be related to a feature or bug or whatever you choose to call it of some MCP23017.

The answer seems to be don't use A7 or B7 as inputs.

See https://www.raspberrypi.org/forums/viewtopic.php?p=637787

| improve this answer | |

I've figured it out. It's not a bug. Is it the conversion between Hex and Binary. I think is the way that Python do the conversion, that removing the first 0 and just show 1111111.

| improve this answer | |
  • However this is still a known bug of the MCP23017. – joan Dec 11 '16 at 22:43
  • Please accept your own answer with a click on the tick on its left side. Only this will finish the question and it will not pop up again year for year. – Ingo Jan 6 at 21:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.