MPU6050 return only 0's

I wanted to play around with a MPU650 a little bit (on Arduino Nano IoT 33). My plan was to print out the raw values at first but I only get this values:

My code looks like this:

#include "Wire.h" 
#define MPU6050_ADDR 0x68 // Alternatively set AD0 to HIGH  --> Address = 0x69
int16_t accX, accY, accZ, gyroX, gyroY, gyroZ, tRaw; // Raw register values (accelaration, gyroscope, temperature)
char result[7]; // temporary variable used in convert function
void setup() {
  Wire.write(0x6B); // PWR_MGMT_1 register
  Wire.write(0); // wake up!
void loop() {
  Wire.write(0x3B); // starting with register 0x3B (ACCEL_XOUT_H)
  Wire.endTransmission(false); // the parameter indicates that the Arduino will send a restart. 
                               // As a result, the connection is kept active.
  Wire.requestFrom(MPU6050_ADDR, 14, true); // request a total of 7*2=14 registers
  // "<<8 |;" means two registers are read and stored in the same int16_t variable
  accX =<<8 |; // reading registers: 0x3B (ACCEL_XOUT_H) and 0x3C (ACCEL_XOUT_L)
  accY =<<8 |; // reading registers: 0x3D (ACCEL_YOUT_H) and 0x3E (ACCEL_YOUT_L)
  accZ =<<8 |; // reading registers: 0x3F (ACCEL_ZOUT_H) and 0x40 (ACCEL_ZOUT_L)
  tRaw =<<8 |; // reading registers: 0x41 (TEMP_OUT_H) and 0x42 (TEMP_OUT_L)
  gyroX =<<8 |; // reading registers: 0x43 (GYRO_XOUT_H) and 0x44 (GYRO_XOUT_L)
  gyroY =<<8 |; // reading registers: 0x45 (GYRO_YOUT_H) and 0x46 (GYRO_YOUT_L)
  gyroZ =<<8 |; // reading registers: 0x47 (GYRO_ZOUT_H) and 0x48 (GYRO_ZOUT_L)
  Serial.print("AcX = "); Serial.print(toStr(accX));
  Serial.print(" | AcY = "); Serial.print(toStr(accY));
  Serial.print(" | AcZ = "); Serial.print(toStr(accZ));
  // from data sheet:
  Serial.print(" | tmp = "); Serial.print((tRaw + 12412.0) / 340.0);
  Serial.print(" | GyX = "); Serial.print(toStr(gyroX));
  Serial.print(" | GyY = "); Serial.print(toStr(gyroY));
  Serial.print(" | GyZ = "); Serial.print(toStr(gyroZ));
char* toStr(int16_t character) { // converts int16 to string and formatting
  sprintf(result, "%6d", character);
  return result;

I don´t really know what is wrong and I am quite new to this stuff. I hope you can help me.

Thanks in advance!

With new I2C devices, always check your connections by running the I2C Address Scanner program.

If you are using the 3.3V MPU-6050 with a 5v Arduino, you need a 5V to 3.3V level shifter on the two I2C connections. Best to use a 3.3V Arduino and make the connections directly.

Finally, MAKE SURE that the required pullup resistors are installed on SCL and SDA.

Thank you the 5V were the problem.

The Arduino Nano IoT 33 uses the ATSAMD21G processor with onboard pullup resistors of 4k7. So it is perfect for 3.3V sensors.

It depends on the extra components on the module, what the best way is to connect it.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.