MPU-6050 raw data

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
mgale31
 
Posts: 16
Joined: Fri Feb 09, 2018 5:51 pm

MPU-6050 raw data

Post by mgale31 »

I have the adafruit MPU-6050 breakout, and would like to get the fastest possible sample rate, I do not need gyro or temp data. How can I get only the acceleration raw data (not G's)?

User avatar
sj_remington
 
Posts: 997
Joined: Mon Jul 27, 2020 4:51 pm

Re: MPU-6050 raw data

Post by sj_remington »

Arduino code

Code: Select all

// MPU-6050 Short Example Sketch
// By Arduino User JohnChi
// August 17, 2014
// Public Domain
#include<Wire.h>
const int MPU_addr = 0x68; // I2C address of the MPU-6050
int16_t AcX, AcY, AcZ;

void setup() {
  Wire.begin();
  Wire.beginTransmission(MPU_addr);
  Wire.write(0x6B);  // PWR_MGMT_1 register
  Wire.write(0);     // set to zero (wakes up the MPU-6050)
  Wire.endTransmission(true);
  Serial.begin(115200);
}

void loop() {
  Wire.beginTransmission(MPU_addr);
  Wire.write(0x3B);  // starting with register 0x3B (ACCEL_XOUT_H)
  Wire.endTransmission(false);
  Wire.requestFrom(MPU_addr, 6); // request a total of 6 registers
  int t = Wire.read();
  AcX = (t << 8) | Wire.read(); // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)
  t = Wire.read();
  AcY = (t << 8) | Wire.read(); // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
  t = Wire.read();
  AcZ = (t << 8) | Wire.read(); // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L)
  Serial.print(AcX);
  Serial.print(", "); Serial.print(AcY);
  Serial.print(", "); Serial.println(AcZ);
}

User avatar
mgale31
 
Posts: 16
Joined: Fri Feb 09, 2018 5:51 pm

Re: MPU-6050 raw data

Post by mgale31 »

Thanks!

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”