MPU6050 library not working with QT Py RP2040

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
ploureiro
 
Posts: 2
Joined: Mon Aug 07, 2017 2:08 pm

MPU6050 library not working with QT Py RP2040

Post by ploureiro »

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

Code: Select all

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

Scanning...
I2C device found at address 0x68  !
done

User avatar
adafruit_support_carter
 
Posts: 29150
Joined: Tue Nov 29, 2016 2:45 pm

Re: MPU6050 library not working with QT Py RP2040

Post by adafruit_support_carter »

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

mpu.begin(MPU6050_I2CADDR_DEFAULT, &Wire1);
Which I2C scanner code were you using? A similar issue should have happened there.

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

Re: MPU6050 library not working with QT Py RP2040

Post by ploureiro »

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

#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
}

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

Return to “Other Products from Adafruit”