2

I am trying to use an MMA8452Q accelerometer with the Raspberry pi B+.

I have it hooked up to 5 GPIO pins on the Pi, J8 pins 1/3/5/7/9. After installing some i2c libraries, the Pi recognizes the device with i2cdetect, on address 0x1d.

However, when I try to read from the device, I always get back a 0 reading.

Further research uncovered that the accelerator needs a repeated start in order to turn it on, but it is unsupported by the hardware.

How would you emulate the repeated start on the Raspberry Pi, or is there another way to get it working?

RPiAwesomeness
  • 3,001
  • 4
  • 30
  • 51
eliotn
  • 121
  • 3

3 Answers3

2

If you are using SMB library, try changing the N to a Y in the file /sys/module/i2c_bcm2708/parameters/combined. This worked for me.

Greenonline
  • 2,740
  • 4
  • 23
  • 36
Dave
  • 21
  • 2
2

I had exactly the same problem, i.e. repeated start failing. I ended up using the pigpio library. See the answer to the question Is there an I2C Library for an example of using the pigpio library to do repeated starts. See the answer to Has anyone successfully used I2C repeated starts on the PI2? My scope says they are broken for when I was having problems and the author of pigpio provided a quick and useful answer.

crj11
  • 493
  • 4
  • 9
2
sudo modprobe -r i2c_bcm2708

sudo modprobe i2c_bcm2708 baudrate=400000 combined=Y

In the second line I also changed the I2C clock rate. I hope this helps.

Darth Vader
  • 4,206
  • 24
  • 45
  • 69
mike449
  • 21
  • 1