daw87uk
Posts: 3
Joined: Sat Apr 07, 2018 8:47 pm

Conflict between ic2-bus and GPIO pins?

Sun Jan 06, 2019 7:46 pm

Hi

I have a Pi 3 controlling GPIO pins and also IO PI expander.

It's been working fine but now there are problems after I've been tinkering with other code. I've narrowed it down to the problem being caused by the setting of the GPIO pins.

For example, if I run the following after the Pi boots (and without running any other code)...

Code: Select all

echo "2" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio2/direction
echo "3" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio3/direction
...then I get the following error when running a test script for the IO PI expander, even though there's no apparent connection (physical or otherwise) between those GPIO pins and the IO PI expander:

Code: Select all

Failed to import IOPi from python system path
Importing from parent folder instead
Traceback (most recent call last):
  File "ht1.py", line 111, in <module>
    main()
  File "ht1.py", line 44, in main
    iobus2 = IOPi(0x21)
  File "../IOPi.py", line 117, in __init__
    self.__ioaddress, self.IOCON, self.__ioconfig)
IOError: [Errno 5] Input/output error
Does anyone know why the setting of the GPIO pins would upset the ic2-bus?

Thanks.

ghp
Posts: 1517
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: Conflict between ic2-bus and GPIO pins?

Sun Jan 06, 2019 9:34 pm

Hello, not sure what this "IO PI expander" is, but possibly a MCP23017 driven by I2C-signals. These I2C-signals are usually provided by GPIO-2, GPIO-3 . Setting these pins to specific directions could conflict with the I2C driver.
Do you have a link to this product (including schematic ?)

daw87uk
Posts: 3
Joined: Sat Apr 07, 2018 8:47 pm

Re: Conflict between ic2-bus and GPIO pins?

Mon Jan 07, 2019 8:11 pm

Thanks for your reply.

You're right - I recently added pins 2 & 3 to what I was doing and that created a conflict, as things worked again when I removed them from the code!

For info, the IO Pi expander schematic is on this page - https://www.abelectronics.co.uk/p/54/io-pi-plus

Thanks. :mrgreen:

Return to “Python”