Go Down

Topic: Can't address the MMA8451 via Arduino Due (Read 1 time) previous topic - next topic


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: [Select]

#include "Wire.h"

#define mma8451_address 0x1D
#define device_id_address 0x0D

void setup() {

void loop() {
  // Read MMA8451 ID
  Wire1.requestFrom(mma8451_address, 1);
  unsigned char data = Wire1.read();
  Serial.print("MMA8451 ID # = ");
  Serial.println(data, HEX);   

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.



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:

Good luck,


Go Up