Pages: [1]   Go Down
Author Topic: Can't address the MMA8451 via Arduino Due  (Read 548 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I’m struggling to get the MMA8451 accelerometer from Freescale to work with the Arduino Due. The following code, which is supposed to read the device ID number, doesn’t appear to work.

Code:
#include "Wire.h"

#define mma8451_address 0x1D
#define device_id_address 0x0D

void setup() {
  Serial.begin(9600);
  Wire1.begin();
}

void loop() {
  // Read MMA8451 ID
  Wire1.beginTransmission(mma8451_address);
  Wire1.write(device_id_address);
  Wire1.endTransmission(false);
  Wire1.requestFrom(mma8451_address, 1);
  unsigned char data = Wire1.read();
  Wire1.endTransmission();
  Serial.print("MMA8451 ID # = ");
  Serial.println(data, HEX);   
  delay(1000);
}

The above code retrieves 0x00 from the device_id_address which is obviously incorrect.

I’m using Arduino’s Wire library and I believe the device is properly connected to the Due board. I have set the SA0 pin to High and the I2C wires are connected to the SCL1 and SDA1 pins on the Due. Two 10K pull-up resistors are also used.

I wonder if the Wire library is fully compatible with the MMA8451 or if it needs to be modified. Has anyone been able to communicate with this device via Arduino Due? Any help with this issue is appreciated.

Thanks

Logged

White River Junction, Vermont USA
Offline Offline
Full Member
***
Karma: 5
Posts: 106
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The last I knew (and perhaps it's been fixed by now), is that endTransmission(false) does not work.  It is simply skipped in the 'wire' library, and you will need to code around it. 

Search the forum for I2C and/or "Repeated Start" to see some past experiences.

Here's one I could remember:
http://forum.arduino.cc/index.php?topic=144700.0

Good luck,

-Chris
Logged

Pages: [1]   Go Up
Jump to: