0

MPU6050 library not working with QT Py RP2040
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

MPU6050 library not working with QT Py RP2040

by ploureiro on Sat Jun 25, 2022 9:49 am

The example code on the Adafruit MPU6050 library
seems to be not compatible with the QT Py RP2040 board.

Code: Select all | TOGGLE FULL SIZE
Error message: "Adafruit MPU6050 test! Failed to find MPU6050 chip"

I guess this is because the QT Py RP2040 uses I2C1 to communicate with the MPU6050, but the example code uses I2C0.

The I2C scanner test detects the MPU6050 correctly.

Code: Select all | TOGGLE FULL SIZE
Scanning...
I2C device found at address 0x68  !
done

ploureiro
 
Posts: 2
Joined: Mon Aug 07, 2017 2:08 pm

Re: MPU6050 library not working with QT Py RP2040

by adafruit_support_carter on Mon Jun 27, 2022 6:07 pm

Yep, if you're using the STEMMA QT connector, it'll end up being Wire1, not the default Wire. You can specify the alternate bus in the call to begin(). Must also specify the address when doing so, but can just reused the default define:
Code: Select all | TOGGLE FULL SIZE
mpu.begin(MPU6050_I2CADDR_DEFAULT, &Wire1);


Which I2C scanner code were you using? A similar issue should have happened there.

adafruit_support_carter
 
Posts: 24070
Joined: Tue Nov 29, 2016 2:45 pm

Re: MPU6050 library not working with QT Py RP2040

by ploureiro on Sat Jul 02, 2022 5:02 am

Thank you for your quick response. The program is working properly now.

For information, I used this I2C scanner (I don't remember the origin of this code)

Code: Select all | TOGGLE FULL SIZE
#include <Wire.h>
 
void setup()
{
  Wire1.begin();
  Serial.begin(9600);
  Serial.println("\nI2C Scanner");
}
 
void loop()
{
  byte error, address;
  int nDevices;
 
  Serial.println("Scanning...");
 
  nDevices = 0;
  for(address = 1; address < 127; address++ )
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire1.beginTransmission(address);
    error = Wire1.endTransmission();
 
    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");
 
      nDevices++;
    }
    else if (error==4)
    {
      Serial.print("Unknow error at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.println(address,HEX);
    }   
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");
 
  delay(5000);           // wait 5 seconds for next scan
}

ploureiro
 
Posts: 2
Joined: Mon Aug 07, 2017 2:08 pm

Please be positive and constructive with your questions and comments.