Benny H.
Benny H.

Reputation: 449

Beaglebone Black and the MCP230xx CircuitPython Library

I don't know how to specify the I2C Bus, because the Beaglebone Black has 3x (1x is not accessible via Header). I want to use both of them for many different I2C devices (Pin 17/18 I2C1 and Pin 19/20 I2C2)

2x I2C SCL/SDA Devices

In the example they mention here: https://github.com/adafruit/Adafruit_CircuitPython_MCP230xx/blob/master/examples/mcp230xx_simpletest.py

import board
import busio

from adafruit_mcp230xx.mcp23008 import MCP23008

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

They only use mcp = MCP23017(i2c, address=0x21) to specify the address of the I2C Device, not the specific Bus. I checked on the "busio" library if I'm able to do it there, but couldn't find a correct declaration.

EDIT: It seems the board-library is doing this kind of stuff. By writing down dir (board) in a python shell it lists all accessible pins on the beaglebone black.

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']

But I have no clue what is the right addressing of the board.pin for I2C. By just handling the definet pin he throws me a error:

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

It seems he recognize the two I2C-Bus-Lines. But I dont know how to address the second one.

Upvotes: 0

Views: 391

Answers (1)

To use I2C1:

i2c = busio.I2C(board.pin.I2C1_SCL, board..pin.I2C1_SDA)

Upvotes: 0

Related Questions