python library for Accelerometer (MMA8452Q)

341 views
Skip to first unread message

John Nivard

unread,
Apr 1, 2013, 11:45:22 AM4/1/13
to quick2wi...@googlegroups.com
Hai

I am looking for a python library to manipulate the readings 
from the Accelerometer (MMA8452Q)

I saw some coding to connect the MMA8452Q and that was not in python

John

Andrew Scheller

unread,
Apr 1, 2013, 2:04:21 PM4/1/13
to quick2wi...@googlegroups.com
> I am looking for a python library to manipulate the readings
> from the Accelerometer (MMA8452Q)
>
> I saw some coding to connect the MMA8452Q and that was not in python

Just did a quick google, and this thread:
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=37&t=35306
suggests that the chip you've chosen has compatibility problems with
the RPi's I2C controller, although it looks like someone's managed to
come up with a workaround:
http://raspberry.znix.com/2013/03/i2c-repeated-start-for-all.html


But in general, most I2C devices are designed for embedded devices &
microcontrollers (i.e. programs written in C or assembler), so unless
it's a *very* popular device, you're unlikely to find python example
code for a particular I2C device. Always best to do a bit of google
research and/or datasheet reading before purchasing :)

Andrew

Kevin Russell

unread,
Aug 25, 2015, 3:26:46 PM8/25/15
to Quick2Wire Users, raspb...@loowis.durge.org
Hey Andrew,

Just a quick question on this... I've recently run into the problem you are discussing in this thread.

Its understandable that Python doesn't interface well at these very low level protocols due to its slower speed and higher overhead.

In a situation where you were interfacing an embedded nix device like a raspberry pi to an i2c devide would you rather:
1) Write a standalone C program and interface through sockets 

-or-

2) Write C code and embed it in python to use natively.

-or- 

3) Use python directly

-or-

4) Some other thing that I'm unawares of

Andrew Scheller

unread,
Aug 26, 2015, 5:33:03 AM8/26/15
to Quick2Wire Users
Hi Kevin,

It's not something I've personally ever done before, but if I was
faced with the situation you're describing I'd start out using python
directly (using one of the i2c libraries), and then only *if* it
turned out that python was too slow to "keep up" with the device, I'd
look at switching to some kind of C-based solution (assuming the
Raspberry Pi 2 was too slow as well).
But as I've never done this, I dunno what C-based approach would be
best. I'd probably look for existing examples, and try modifying them
to suit my needs?

Best of luck,
Andrew

Romilly Cocking

unread,
Aug 26, 2015, 5:46:19 AM8/26/15
to quick2wi...@googlegroups.com
Kevin, I've never encountered a situation where Python on the Pi was too slow for an I2C interface.

I have met a few situations where I2C itself was too slow. In those circumstances a C program offers no significant advantage.

If I did find a situation where Python's speed was the problem I would probably go for a C program that communicated with Python using zeromq.

--
You received this message because you are subscribed to the Google Groups "Quick2Wire Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to quick2wire-use...@googlegroups.com.
Visit this group at http://groups.google.com/group/quick2wire-users.
For more options, visit https://groups.google.com/d/optout.



--
Reply all
Reply to author
Forward
0 new messages