Quantcast
Channel: fritzing forum - Latest posts
Viewing all articles
Browse latest Browse all 29702

MMA8451Q Breakout board - 'MMA8451Q couldn't start'

$
0
0

I'm currently working on a project 'Human Fall detection' using MMA8451Q accelerometer. I'm using MMA8451Q breakout board from Adafruit and Arduino Uno. I had downloaded the Adafruit library for MMA8451Q sensor and tried to run the demo code in Arduino IDE. But, it is showing 'Couldn't Start' in the serial monitor when I run this code:

include

include

include

Adafruit_MMA8451 mma = Adafruit_MMA8451();

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

Serial.println("Adafruit MMA8451 test!");
mma.begin();

if (! mma.begin()) {
Serial.println("Couldnt start");
while (1);
}
Serial.println("MMA8451 found!");

mma.setRange(MMA8451_RANGE_2_G);

Serial.print("Range = "); Serial.print(2 << mma.getRange());
Serial.println("G");

}

void loop() {
// Read the 'raw' data in 14-bit counts
mma.read();
Serial.print("X:\t"); Serial.print(mma.x);
Serial.print("\tY:\t"); Serial.print(mma.y);
Serial.print("\tZ:\t"); Serial.print(mma.z);
Serial.println();

/* Get a new sensor event */
sensors_event_t event;
mma.getEvent(&event);

/* Display the results (acceleration is measured in m/s^2) */
Serial.print("X: \t"); Serial.print(event.acceleration.x); Serial.print("\t");
Serial.print("Y: \t"); Serial.print(event.acceleration.y); Serial.print("\t");
Serial.print("Z: \t"); Serial.print(event.acceleration.z); Serial.print("\t");
Serial.println("m/s^2 ");

/* Get the orientation of the sensor */
uint8_t o = mma.getOrientation();

switch (o) {
case MMA8451_PL_PUF:
Serial.println("Portrait Up Front");
break;
case MMA8451_PL_PUB:
Serial.println("Portrait Up Back");
break;
case MMA8451_PL_PDF:
Serial.println("Portrait Down Front");
break;
case MMA8451_PL_PDB:
Serial.println("Portrait Down Back");
break;
case MMA8451_PL_LRF:
Serial.println("Landscape Right Front");
break;
case MMA8451_PL_LRB:
Serial.println("Landscape Right Back");
break;
case MMA8451_PL_LLF:
Serial.println("Landscape Left Front");
break;
case MMA8451_PL_LLB:
Serial.println("Landscape Left Back");
break;
}
Serial.println();
delay(500);

}

Initially, I thought the sensor is not detected because it is not soldered but I removed this part of the code
if (! mma.begin()) {
Serial.println("Couldnt start");
while (1);
}
and uploaded it, I could see the 'Sensor is found' and some X, Y,Z values but all the values are same and they hadn't changed when I changed the orientation of the sensor.
Could anyone please help me out with this issue?


Viewing all articles
Browse latest Browse all 29702

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>