Grovepi Accelerometer Issues

We are working on a project with the Grovepi and the accelerometer. We have been getting the values (-31, -31, -31) consistently from the accelerometer, even when we move it around. What can we do to fix this?

Also, we have been getting an IOError from the module adx1345.py from the line bus.write_byte_data(self.address, BW_Rate, rate_flag), and we were wondering how to solve that.

Thanks

Hey,
Which accelerometer are you using right now. There are a couple of them in Grove.

Also can you run i2cdetect -y 1 and paste the output here.

Thanks,
Karan

Here is the i2c detect data:

pi@raspberrypi ~ $ sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: – 04 – -- – -- – -- – -- – -- –
10: – -- – -- – -- – -- – -- – -- – -- – --
20: – -- – -- – -- – -- – -- – -- – -- – --
30: – -- – -- – -- – -- – -- – -- – -- – --
40: – -- – -- – -- – -- – -- – -- – -- – --
50: – -- – -- – -- – -- – -- – -- – -- – --
60: – -- – -- – -- – -- – -- – -- – -- – --
70: – -- – -- – -- – --

Hey,
Your GrovePi looks fine, can you send a link to which module you are using and to which port you are connecting the accelerometer too.

-Karan

smbustimemathRPI
GPIOstruct

Both are imported into grovepi.py. We’re using the i2c-1 port.

Hey,
The problem that I think you are facing is that the I2C module is not being detected at all by the Raspberry Pi. You might be having a dead sensor with you. If you could post a link or the name of the sensor that you re using, then that would be pretty helpful.

-Karan

Here’s the link:
http://www.seeedstudio.com/wiki/Grove_-_3-Axis_Digital_Accelerometer(±16g)

Hey,
Can you plug in the accelerometer in any of the I2C ports on the GrovePi and run i2cdetect -y 1, you should see a number at 53 or something like that similar to 04. If you don’t see that then I think most probably the sensor is broken.

-Karan

We ran it again on all of the ports and it gave us the same results as before.

If you are not getting anything apart from 04 from the i2cdetect command and you are sure that the sensor is connected to the I2C port on the GrovePi, then I think the sensor that you are using might not be working. You should try getting it to work with the arduino or get in touch from where you bought it and ask for a replacement.

-Karan

Hi,

I am facing a similar issue, I recently purchased the GrovePi+ and hooked it up to my Raspberry Pi 2. Initial set-up seemed to work fine. I hooked up a grove 3-axis accelerometer (v1.1 produced by seeedstudio).

The sensor was detected running sudo i2cdetect -y 1 …

 0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f

00: – 04 – -- – -- – -- – -- – -- –
10: – -- – -- – -- – -- – -- – -- – -- – --
20: – -- – -- – -- – -- – -- – -- – -- – --
30: – -- – -- – -- – -- – -- – -- – -- – --
40: – -- – -- – -- – -- – -- – -- 4c – -- –
50: – -- – -- – -- – -- – -- – -- – -- – --
60: – -- – -- – -- – -- – -- – -- – -- – --
70: – -- – -- – -- – --

I can also read values back with the following code…

import time
from grovepi import *

while True:
try:

            accl = acc_xyz()        # Get the value from the accelerometer
            print "\nX:",accl[0],"\tY:",accl[1],"\tZ:",accl[2],
            time.sleep(.1)
    except KeyboardInterrupt:       # Stop the buzzer before stopping
            break
    except (IOError,TypeError) as e:
            print "Error"

However when I try to run the python script adx1345.py under ~/GrovePi/Software/Python/grove_accelerometer_16g I get the following error…

Traceback (most recent call last):
File “adxl345.py”, line 105, in <module>
adxl345 = ADXL345()
File “adxl345.py”, line 47, in init
self.setBandwidthRate(BW_RATE_100HZ)
File “adxl345.py”, line 55, in setBandwidthRate
bus.write_byte_data(self.address, BW_RATE, rate_flag)
IOError: [Errno 5] Input/output error

Any advice how to fix this problem… ?

I solved this, needed to change the address in adxl345.py from 0x53 to 0x4c …

Hey,
The example for the accelerometer was for this http://www.seeedstudio.com/depot/Grove-3Axis-Digital-Accelerometer16g-p-1156.html?cPath=25_132 (this has ADXL345 chip and has the address 0x53). I think the module that you are using is http://www.seeedstudio.com/depot/Grove-3Axis-Digital-Accelerometer15g-p-765.html?cPath=25_132 which has a completely different chip MMA7660 having the address 0x4C. Looking at the datasheet for the two sensors, the data is at different registers and the reading that you are getting might not be the right readings. Just wanted to check if you are getting good values with the accelerometer or is it behaving erratically.

-Karan

Hi Karan

Thanks for the reply, rather than accessing the accelerometer directly through an i2c read I would rather use the commands available from the GrovePi.

I tried the acc_xyz() function in the grovepi.py but not sure what it is actually doing other than reading back the x,y,z values and adjusting the negative values. I would like to see what commands the grovepi is actually sending to the accelerometer. Where can I see this code?

Am I right in thinking that the “unused” parameters are just written as a block of 3 bytes to the command register on the accelerometer? write_i2c_block(address, acc_xyz_cmd + [unused, unused, unused]) and I can add extra parameters to the list to write to the other command registers as specified on the chip’s datasheet?

-Dan.

Hey Dan,
On the Raspberyy Pi side, here is the implementaiton in Python: https://github.com/DexterInd/GrovePi/blob/master/Software/Python/grovepi.py#L262-L273 and one the firmware side here is the implementation: https://github.com/DexterInd/GrovePi/blob/master/Firmware/Source/v1.2/grove_pi_v1_2_2/grove_pi_v1_2_2.ino#L94-L105 . Bsically, we use the MMA7660 header to read and load the values into the buffer.

Basically, this code is there since the very beginning of the GrovePi and we found that it is better to directly access all the I2C devices from the Raspberry Pi so that would definitely be the recommended way to use it.

-Karan