6

I have a MMA845X accelerometer mapped at 1C:

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- 1c -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

I use this python script to get some results

import smbus
DEVICE_ADDRESS = 0x1c
MMA8451_REG_WHOAMI = 0x0D
bus = smbus.SMBus(1)
ret = bus.read_byte_data(DEVICE_ADDRESS, MMA8451_REG_WHOAMI)
print ret

but I get always 0.

After a small research I find out that this sensor require repeated start and that repeated start is not available for Raspberry Pi.

How do I make it work?

2
  • What model Pi are you using? what Distro are you using and what version is it? Feb 28, 2016 at 18:16
  • Raspberry Pi B 2 , Raspbian Jessie 8 Feb 28, 2016 at 18:19

2 Answers 2

0

It may be possible to get repeated starts to work with the following command.

sudo sh -c 'echo "Y" >/sys/module/i2c_bcm2708/parameters/combined'

Try that and see if your script works.

5
  • Now I get constantlly 42 Feb 28, 2016 at 20:42
  • I think it might be a problem with MMA8451_REG_WHOAMI = 0x0D , I don't know what this address is. Feb 28, 2016 at 20:44
  • 0x0d (decimal 13) is the correct register address. It should return 0x1a (26). pigpio will let you bit bang repeated starts using bb_i2c_zip. Depends on how far your programming skills have developed.
    – joan
    Feb 28, 2016 at 20:53
  • I get 0x2a What does that mean? Feb 28, 2016 at 20:56
  • I have no idea apart from it isn't the expected documented value.
    – joan
    Feb 28, 2016 at 20:59
0

you are not sending the correct data. if you are looking for a complete code you can get here. MMA845X Python code

go to resources tab you will find the code.

make sure your sensor is connected correctly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.