jrowberg / i2cdevlib

I2C device library collection for AVR/Arduino or other C++-based MCUs
http://www.i2cdevlib.com
3.92k stars 7.52k forks source link

Manage gyro and acc offset on calibration process before interrupt #633

Open MaxESP opened 2 years ago

MaxESP commented 2 years ago

Dear M Jrowberg,

Thanks a lot for your MPU6050 library is the best one i have tried ; i have achieve a tilt compass on esp32 with couple mpu6050 and lsm303dlh.

It's work great about 3 degrees max at -+90° pitch or roll inclination .I going to work to improve the little error.....

I want to achive a automatic calibration using memory but i was not able to manage offset data of gyro and acc on the calibration process on the sketch mpu6050 DMP6 v6v12. Can you please provid the link of the fonction that print those values on serial monitor.

yours faithfully

ZHomeSlice commented 2 years ago

mpu.PrintActiveOffsets(); does the printing of the offsets to serial

void MPU6050::PrintActiveOffsets() {
    uint8_t AOffsetRegister = (getDeviceID() < 0x38 )? MPU6050_RA_XA_OFFS_H:0x77;
    int16_t Data[3];
    if(AOffsetRegister == 0x06) I2Cdev::readWords(devAddr, AOffsetRegister, 3, (uint16_t *)Data);
    else {
        I2Cdev::readWords(devAddr, AOffsetRegister, 1, (uint16_t *)Data);
        I2Cdev::readWords(devAddr, AOffsetRegister+3, 1, (uint16_t *)Data+1);
        I2Cdev::readWords(devAddr, AOffsetRegister+6, 1, (uint16_t *)Data+2);
    }
    printf("\nOffset Values on device:\n");
    //  A_OFFSET_H_READ_A_OFFS(Data);
    printf("Acc. X = %d, Y = %d, Z = %d\n", Data[0], Data[1], Data[2]);
    I2Cdev::readWords(devAddr, 0x13, 3, (uint16_t *)Data);
    //  XG_OFFSET_H_READ_OFFS_USR(Data);    
    printf("Gyro. X = %d, Y = %d, Z = %d\n", Data[0], Data[1], Data[2]);
}

Z

MaxESP commented 2 years ago

thank a lot M JROWBERG i am going to try manage those values before interrupt and put them in memory

MaxESP commented 2 years ago

Thank M ZhomeSlice i was able to store them in memory thanks a lot

how can I manage mpu.setXGyroOffset(42) ; mpu.setYGyroOffset(99); mpu.setZGyroOffset(79); mpu.setXAccelOffset(-919); mpu.setYAccelOffset(2015); mpu.setZAccelOffset(1697);

to put the value memory in mpu.setXGyroOffset(?) ;

MaxESP commented 2 years ago

I want to presise my previous post.

1 The function printf the values of the array 2 I am able to store those value as a json format in spiffs 3 Now i have to set a x value for int 16-t for mpu.setXGyroOffset(x) ; x =0; 4 imput the new int16_t value(mpu.setXGyroOffset(x)) from json declare the new value of x;

I am stuck in point 4 to convert int value x from json to int16_t value declaration