diabloj13
Posts: 2
Joined: Mon Mar 24, 2014 3:59 pm

MMA7455 with Raspberry Pi

Mon Mar 24, 2014 4:13 pm

Hi, I have a project a school where I am to use the MMA7455 sensor to sense and store information in 3 dimensions and then show a graph of the accelerometer readings in a jump. I have managed to make the MMA7455 sensor work with an Arduino, but the Arduino has too little storage space and so I have to use a Raspberry Pi. I'm a complete noob with Raspberry, but I've managed to install i2c-tools, python-smbus and make a python script following this guide:

http://www.themagpi.com/issue/issue-4/a ... lerometer/

Now that I had done everything the guide said, I couldn't get it to work, and I've seen other posts complaining about the guide aswell. Can someone guide me? I've already changed the b = smbus.SMBus(0) to b = smbus.SMBus(1), because I'm using i2c. I'm still getting an error that says:

Traceback (most recent call last):
File "MMA7455.py", line 25, in <module>
class Accel():
File "MMA7455.py", line 26, in Accel

b = smbus.SMBus(1)
IOError: [Errno 13] Permission denied

Thank you :)

Tarcas
Posts: 741
Joined: Thu Jan 09, 2014 5:38 am
Location: USA

Re: MMA7455 with Raspberry Pi

Tue Mar 25, 2014 12:53 am

IOError: [Errno 13] Permission denied
Are you running the python script as root (using sudo?) The Pi user doesn't have permissions to read and write the GPIO pins, so you need to use escalated privileges.

diabloj13
Posts: 2
Joined: Mon Mar 24, 2014 3:59 pm

Re: MMA7455 with Raspberry Pi

Tue Mar 25, 2014 8:48 am

Thank you, that helped :)

I've managed to get the program to draw a graph, but it wil only draw a straight line. Whenever the sensor gets input the program crashes and gives me the error:

Traceback (most recent call last):
File “MMA7455.py”, line 39, in <module>
Aval = MMA7455.getValue()
File “MMA7455.py”, line 28, in getValue
self.b.write_byte_data(0x1D, 0x16, 0x45)
IOError: [Errno 5] Input/output error

If I keep running the program over an over this line of error code sometimes changes:

“ File “MMA7455.py”, line 28, in getValue
self.b.write_byte_data(0x1D, 0x16, 0x45)”

to

“ File “MMA7455.py”, line 30, in getValue
l = self.b.read_byte_data(0x1D, 00)”

But the program that MagPi made gives me a real-time graph, and I'm really not interested in that. I only want the data stored on the memory card and then I can make graphs later. Also this program is in 1 dimension, I would prefer it to store information X, Y and Z.

walt
Posts: 17
Joined: Wed Apr 02, 2014 3:32 am
Location: boston

Re: MMA7455 with Raspberry Pi

Tue Oct 14, 2014 11:28 am

please note

Code: Select all

 b = smbus.SMBus(0) 
should be replace if necessary
SMBus(0) --> A, i2c-0 bus
SMBus(1) --> B,B+,.... i2c-1 bus

Return to “Automation, sensing and robotics”