MPU9250 Library problem with calibration offset procedures

I'm using the latest version of the MPU9250 library that I just downloaded from the Arduino repository and a Sparkfun Thing Plus C processor (ESP32 WROOM 32E). I ran calibration example to get calibration offset and ranges values for the acceleration, gyro and magnetometers sensors. Wanted to load these into a test program to see if I could get accurate data from the mag sensor. Upon compiling I get error messages (e.g.; setGyroBias' was not declared in this scope) from the setAccBias(), setGyroBias() and setMagBias() procedure calls. These procedures are clearly defined in the MPU9250.h header file.

I admit I am no coding guru, but this seems perplexing. Can anyone give me a hint as to why I'm getting these compiler errors?

#include "MPU9250.h"

MPU9250 mpu;

void setup() {
    Serial.begin(115200);
    Wire.begin();
    delay(2000);

    if (!mpu.setup(0x69)) {  // change to your own address
        while (1) 
        {
            Serial.println("MPU connection failed. Please check your connection with `connection_check` example.");
            delay(5000);
        }
    }
    setAccBias(28.61, 8.43, 341.56);
    setGyroBias(-1.44, -0.92, 0.27);
    setMagBias(16.13, 129.46, -374.47);
    setMagScale(1.06, 0.98, 0.97);
    setMagneticDeclination(-3.6);
    }

void loop() {
    if (mpu.update()) {
        static uint32_t prev_ms = millis();
        if (millis() > prev_ms + 25) {
            print_roll_pitch_yaw();
            print_acc();
            print_mag();
            prev_ms = millis();
        }
    }
}
void print_acc()
    {
    Serial.print("Acc_x, Acc_y, Acc_z: ");
    Serial.print(mpu.getAccX(),2);
    Serial.print(", ");
    Serial.print(mpu.getAccY(), 2);
    Serial.print(", ");
    Serial.println(mpu.getAccZ(), 2); 
    }

void print_mag()
    {
    Serial.print("Mag_x, Mag_y, Mag_z: ");
    Serial.print(mpu.getMagX(),2);
    Serial.print(", ");
    Serial.print(mpu.getMagY(), 2);
    Serial.print(", ");
    Serial.println(mpu.getMagZ(), 2); 
    }
   
void print_roll_pitch_yaw() {
    Serial.print("Yaw, Pitch, Roll: ");
    Serial.print(mpu.getYaw(), 2);
    Serial.print(", ");
    Serial.print(mpu.getPitch(), 2);
    Serial.print(", ");
    Serial.println(mpu.getRoll(), 2);
}

Well, i don't know the library, but i'm pretty sure you are missing the class instance:

mpu.setAccBias(28.61, 8.43, 341.56);
mpu.setGyroBias(-1.44, -0.92, 0.27);
mpu.setMagBias(16.13, 129.46, -374.47);
mpu.setMagScale(1.06, 0.98, 0.97);
mpu.setMagneticDeclination(-3.6);

Well, DUH! Thanks. That was it.
:roll_eyes:

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