0

mpu6050 has sampling frequency of 1kHz (mentioned in datasheet). But when i interface it with arduino uno via I2C communication (400Khz bus speed), i only get 50 raw data (each of x,y,z). There is no delay in the program. why is this happening. Why am I not getting 1000 or at least 800 samples. What is the concept I am missing here. Please explain in detail. I have also attached the code and output for 1 second.

#include "I2Cdev.h"
#include "MPU6050.h"
#include "Wire.h"
//#include <SoftwareSerial.h>
//SoftwareSerial BTserial(10,11);
MPU6050 accelgyro;
char ch;
int incomingbyte = 0;
int16_t ax, ay, az;
int16_t gx, gy, gz;

void setup() {

  Wire.begin();
  Serial.begin(115200);

  accelgyro.initialize();
  accelgyro.setXAccelOffset(542);
  accelgyro.setYAccelOffset(-835);
  accelgyro.setZAccelOffset(1651);
  accelgyro.setXGyroOffset(6);
  accelgyro.setYGyroOffset(-18);
  accelgyro.setZGyroOffset(23);
}
void loop()
{
  accelgyro.getAcceleration(&ax, &ay, &az);
  accelgyro.getRotation(&gx, &gy, &gz);

  Serial.print(ax); Serial.print("\t");
  Serial.print(ay); Serial.print("\t");
  Serial.println(az);
}

enter image description here

  • the datasheet indicates that the sample rate is programmable ... looks like register 25 is involved ... this document describes the register functions ... invensense.tdk.com/wp-content/uploads/2015/02/… – jsotola May 3 at 17:18
  • HI @jsotola , thanks for the reply. I found out sampling rate divider that is at reg 0x25 , 255 was set. So the sampling rate should be either 31.25Hz DLPF is disabled or 3.9 hz when DLPF enabled according to the datasheet (pg no 12 in the link you have provided). Still i am getting more than these values around 50 samples. How come? Also sampling rate is different from data transmission rate from mpu6050 to arduino uno right? Can you explain in detail like how many bytes would transmitted through i2c and all those calculation stuffs. I am not getting that – Sreeranjani Sekar May 3 at 18:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.