0

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:
git:/opt/scripts/:[31292bce1d4b35b497cc7a013d6d57e7e1f4f5c4]
eeprom:[A335PBGL00A21743GPB41756]
model:[TI_AM335x_PocketBeagle]
dogtag:[BeagleBoard.org Debian Image 2018-06-17]
bootloader:[microSD]:[/dev/mmcblk0]:[U-Boot 2018.03-00002-gac9cce7c6a]:[location: dd MBR]
kernel:[4.14.49-ti-r54]
nodejs:[v6.14.3]
uboot_overlay_options:[enable_uboot_overlays=1]
uboot_overlay_options:[uboot_overlay_pru=/lib/firmware/AM335X-PRU-RPROC-4-14-TI-00A0.dtbo]
uboot_overlay_options:[enable_uboot_cape_universal=1]
pkg check: to individually upgrade run: [sudo apt install --only-upgrade <pkg>]
pkg:[bb-cape-overlays]:[4.4.20180611.0-0rcnee0~stretch+20180611]
pkg:[bb-wl18xx-firmware]:[1.20180517-0rcnee0~stretch+20180517]
pkg:[kmod]:[23-2rcnee1~stretch+20171005]
pkg:[roboticscape]:[0.4.4-git20180608.0-0rcnee0~stretch+20180609]
pkg:[firmware-ti-connectivity]:[20170823-1rcnee1~stretch+20180328]
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
END

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?

uhclem
 
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.

uhclem
 
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.

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

Please be positive and constructive with your questions and comments.