Adafruit_BBIO and mma8451
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Adafruit_BBIO and mma8451

by uhclem on Wed Jun 27, 2018 6:47 pm

I'm getting lost trying to get my mma8451 breakout working with my pocketbeagle. I know it's at least wired correctly, as it shows up on the bus.

I've been trying to get this library working https://www.hackster.io/makers-ns/beagl ... 452-4bd45b but run into issues where the library has changed since it was authored.

/opt/scripts/tools/version.sh output:
dogtag:[BeagleBoard.org Debian Image 2018-06-17]
bootloader:[microSD]:[/dev/mmcblk0]:[U-Boot 2018.03-00002-gac9cce7c6a]:[location: dd MBR]
pkg check: to individually upgrade run: [sudo apt install --only-upgrade <pkg>]
groups:[debian : debian adm kmem dialout cdrom floppy audio dip video plugdev users systemd-journal i2c bluetooth netdev cloud9ide gpio pwm eqep admin spi tisdk weston-launch xenomai]
cmdline:[console=ttyO0,115200n8 root=/dev/mmcblk0p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 quiet]
dmesg | grep pinctrl-single
[ 1.097870] pinctrl-single 44e10800.pinmux: 142 pins at pa f9e10800 size 568
dmesg | grep gpio-of-helper
[ 1.106300] gpio-of-helper ocp:cape-universal: ready

Adafruit_BBIO version:
python -c "import Adafruit_BBIO; print Adafruit_BBIO"
<module 'Adafruit_BBIO' from '/usr/local/lib/python2.7/dist-packages/Adafruit_BBIO-1.0.10-py2.7-linux-armv7l.egg/Adafruit_BBIO/__init__.pyc'>

I've changed the original code so that "from Adafruit_I2C import Adafruit_I2C " is now "import Adafruit_GPIO.I2C as I2C" (and updated other instances in the code too).

right now I'm stuck on the following:

Traceback (most recent call last):
File "accel.py", line 7, in <module>
acc = MM8452_ACCEL()
File "/home/alex/mm8452.py", line 37, in __init__
self.i2C = I2C(self.address)
TypeError: 'module' object is not callable

that's here in the library code:
def __init__(self, address = 0x1D):
self.address = address
self.i2C = I2C(self.address)

I'm not sure why it's an issue as I'm not very good with object-oriented python. Is it worth trying to get this older library to work or should I start over from scratch?

Posts: 107
Joined: Sun Jul 08, 2007 6:03 pm

Re: Adafruit_BBIO and mma8451

by uhclem on Thu Jun 28, 2018 3:07 am

I got it to work by looking at one of the other Adafruit i2c BBB sensor libraries and comparing how the address is obtained in the constructor in __init__:

self.i2C = I2C.get_i2c_device(address)

There are probably other changes needed to this library to keep it current with the way other BBIO-type libraries are now written but at least it works. Hopefully this is helpful to someone since Adafruit sells the mma8451 and I don't think there are any accelerometer tutorials for BBB.

Posts: 107
Joined: Sun Jul 08, 2007 6:03 pm

Re: Adafruit_BBIO and mma8451

by drewfustini on Tue Jul 03, 2018 4:27 pm

Thank you for following up and sharing the solution.

Posts: 944
Joined: Sat Dec 26, 2015 1:19 pm

Please be positive and constructive with your questions and comments.