question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Beaglebone Black and MPC23017 PortExpander via I2C

See original GitHub issue

I’m not able to access a MPC via I2C on the Beaglebone Black with the python3 circuitpython library. Beaglebone Black has 3x I2C Ports. 2x are accessable via header. The Pins are P9_17 SCL1 / P9_18 SDA1, and P9_19 SCL2 / P9_20 SDA1.

I want to use the MCP23017 Library to expand the GPIO of the Beaglebone with 2x different I2C-Ports. My first try was to detect simply just one and failed. This is how I want to access the MCP:

import board
import busio
from adafruit_mcp230xx.mcp23017 import MCP23017

i2c = busio.I2C(board.SCL, board.SDA)
mcp = MCP23017(i2c, address = 0x20)  # MCP23017

I see the devices with i2cdetect -y -r 1 if i connect them with P9_17 / P9_18. and with i2cdetect -y -r 2 if i connect them with P9_19 / P9_20.

i2detect -l shows me all 3x ports.

i2c-1   i2c             OMAP I2C adapter                        I2C adapter
i2c-2   i2c             OMAP I2C adapter                        I2C adapter
i2c-0   i2c             OMAP I2C adapter                        I2C adapter

My guessing, the standard board.SCL and board.SDA is pointing at the I2C Port which is not accessable over the P9 header: ValueError: No I2C device at address: 20

Loading the Board-Pins I get following results:

>>> import board
>>> dir (board)
['CE0', 'CE1', 'I2C', 'LED_USR0', 'LED_USR1', 'LED_USR2', 'LED_USR3', 'MISO', 'MISO_1', 'MOSI', 'MOSI_1', 'P8_10', 'P8_11', 'P8_12', 'P8_13', 'P8_14', 'P8_15', 'P8_16', 'P8_17', 'P8_18', 'P8_19', 'P8_20', 'P8_21', 'P8_22', 'P8_23', 'P8_24', 'P8_25', 'P8_26', 'P8_27', 'P8_28', 'P8_29', 'P8_3', 'P8_30', 'P8_31', 'P8_32', 'P8_33', 'P8_34', 'P8_35', 'P8_36', 'P8_37', 'P8_38', 'P8_39', 'P8_4', 'P8_40', 'P8_41', 'P8_42', 'P8_43', 'P8_44', 'P8_45', 'P8_46', 'P8_5', 'P8_6', 'P8_7', 'P8_8', 'P8_9', 'P9_11', 'P9_12', 'P9_13', 'P9_14', 'P9_15', 'P9_16', 'P9_17', 'P9_18', 'P9_19', 'P9_20', 'P9_21', 'P9_22', 'P9_23', 'P9_24', 'P9_25', 'P9_26', 'P9_27', 'P9_28', 'P9_29', 'P9_30', 'P9_31', 'P9_41', 'P9_42', 'SCK', 'SCK_1', 'SCL', 'SCLK', 'SCLK_1', 'SDA', 'SPI', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'ap_board', 'board_id', 'detector', 'pin', 'sys']
>>> 

Using the direct pin where my MPC is connected right now, I get following error:

ValueError: No Hardware I2C on (scl,sda)=(P9_19, P9_20)
Valid I2C ports: ((1, I2C1_SCL, I2C1_SDA), (2, I2C2_SCL, I2C2_SDA))

Tried P9_17 / P9_18 as well of course. Same result. Maybe I’m simply just using the wrong addressing of the pin? I tried some but couldn’t get it to work.

Please help!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:31 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
VirToRealcommented, Jul 1, 2020

No problem - Take you’re time. I try to determent my problem with the fluctuating recognition of the MPC and its cause.

Berlin is very nice, good choice. The prices are very cheap for a huge city like that (except the flats 😉. But still not comparable with Munich. Awesome nightlife and a lot of things to do. Im living in germany too, more landscape like in the northern region of Bavaria near “Weiden in der Oberpfalz”. Welcome to Germany, I’m pretty sure you will like it here.

0reactions
VirToRealcommented, Jul 22, 2020

@pdp7 I dont know what to say, it works perfectly! I can’t thank you enough Drew. Thanks for all your efforts. Sorry for my hardware issue, I testet with just one MPC connected, but murphys law, it was exactly the damaged one out of ten. I should have tested one more. Additionally, I’m able to use both I2C for MPC23017s on the beaglebone black now, thanks alot!

Read more comments on GitHub >

github_iconTop Results From Across the Web

I2C GPIO expanders and the BeagleBoneBlack and ...
OK, I have made use of the MCP23008 and MCP23017, 8 bit and 16 bit GPIO expanders that are I2C connected on Raspberry...
Read more >
MCP23017 - i2c 16 input/output port expander : ID 732 : $6.95
Add another 16 pins to your microcontroller using an MCP23017 port expander. The MCP23017 uses two i2c pins (these can be shared with...
Read more >
Beaglebone Black I2C Tutorial - Teach Me Microcontrollers
In this tutorial, we will look at how to use the I2C protocol on the BBB and create a simple Beaglebone Black I2C...
Read more >
node-red-contrib-i2c-lcd-adafruit-sainsmart - npm
Node for node-red to interact with Adafruit and sainsmart i2c-lcd's. Also units built using MCP23017 i2c port expander and a HD44780 LCD or ......
Read more >
MCP23017 Driver - Gobot
The MCP23017 is a 16-bit input/output port expander. API Reference. How To Connect. Install the package with: go get gobot.io/x/gobot.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found