Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using 2 MPU6050 #32

Open
Gugarauj07 opened this issue Jul 16, 2022 · 1 comment
Open

Using 2 MPU6050 #32

Gugarauj07 opened this issue Jul 16, 2022 · 1 comment

Comments

@Gugarauj07
Copy link

Hey, Im trying to use the setAddress() Method but im still only having the data from the 0x68 device. Can somebody help me?

#include <MPU6050_light.h>
#include "Wire.h"

float currentAngleX_A, currentAngleY_A, currentAngleZ_A;
float currentAngleX_B, currentAngleY_B, currentAngleZ_B;

MPU6050 mpuA(Wire);
MPU6050 mpuB(Wire);

void setup()
{
    Serial.begin(9600);
    Wire.begin();

    mpuA.setAddress(0x68);
    mpuA.begin();
    Serial.println(F("Calculating gyro offset, do not move MPU6050"));
    delay(1000);
    mpuA.calcGyroOffsets();
    Serial.println("Done.");
    
    mpuB.setAddress(0x69);
    mpuB.begin();
    Serial.println(F("Calculating gyro offset, do not move MPU6050"));
    delay(1000);
    mpuB.calcGyroOffsets();
    Serial.println("Done.");
}
void loop()
{
    mpuA.update();
    currentAngleX_A = mpuA.getAngleX();
    currentAngleY_A = mpuA.getAngleY();
    currentAngleZ_A = mpuA.getAngleZ();

    mpuB.update();
    currentAngleX_B = mpuB.getAngleX();
    currentAngleY_B = mpuB.getAngleY();
    currentAngleZ_B = mpuB.getAngleZ();

    Serial.print(currentAngleX_A);
    Serial.print(" , ");
    Serial.print(currentAngleY_A);
    Serial.print(" , ");
    Serial.print(currentAngleZ_A);
    Serial.print(" , ");
    Serial.print(currentAngleX_B);
    Serial.print(" , ");
    Serial.print(currentAngleY_B);
    Serial.print(" , ");
    Serial.print(currentAngleZ_B);
    Serial.println(" ");
}
@TheGuideGH
Copy link

Hi,

Late response, but I came here because I was figuring out how to connect two sensors. Actually you're code helped me, and it works fine! Did you pull pin AD0 high on one of the sensors?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants