Hello everyone,
I was just wondering why this piece of code is not working. Here are the code and the circuit down below.
#include "MPU9250.h"
MPU9250 mpu;
void setup() {
Serial.begin(115200);
Wire.begin();
delay(2000);
if (!mpu.setup(0x68)) { // change to your own address
while (1) {
Serial.println("MPU connection failed. Please check your connection with `connection_check` example.");
delay(5000);
}
}
// calibrate anytime you want to
Serial.println("Accel Gyro calibration will start in 5sec.");
Serial.println("Please leave the device still on the flat plane.");
mpu.verbose(true);
delay(5000);
mpu.calibrateAccelGyro();
Serial.println("Mag calibration will start in 5sec.");
Serial.println("Please Wave device in a figure eight until done.");
delay(5000);
mpu.calibrateMag();
print_calibration();
mpu.verbose(false);
}
void loop() {
}
void print_calibration() {
Serial.println("< calibration parameters >");
Serial.println("accel bias [g]: ");
Serial.print(mpu.getAccBiasX() * 1000.f / (float)MPU9250::CALIB_ACCEL_SENSITIVITY);
Serial.print(", ");
Serial.print(mpu.getAccBiasY() * 1000.f / (float)MPU9250::CALIB_ACCEL_SENSITIVITY);
Serial.print(", ");
Serial.print(mpu.getAccBiasZ() * 1000.f / (float)MPU9250::CALIB_ACCEL_SENSITIVITY);
Serial.println();
Serial.println("gyro bias [deg/s]: ");
Serial.print(mpu.getGyroBiasX() / (float)MPU9250::CALIB_GYRO_SENSITIVITY);
Serial.print(", ");
Serial.print(mpu.getGyroBiasY() / (float)MPU9250::CALIB_GYRO_SENSITIVITY);
Serial.print(", ");
Serial.print(mpu.getGyroBiasZ() / (float)MPU9250::CALIB_GYRO_SENSITIVITY);
Serial.println();
Serial.println("mag bias [mG]: ");
Serial.print(mpu.getMagBiasX());
Serial.print(", ");
Serial.print(mpu.getMagBiasY());
Serial.print(", ");
Serial.print(mpu.getMagBiasZ());
Serial.println();
Serial.println("mag scale []: ");
Serial.print(mpu.getMagScaleX());
Serial.print(", ");
Serial.print(mpu.getMagScaleY());
Serial.print(", ");
Serial.print(mpu.getMagScaleZ());
Serial.println();
}
And here's the error.
In file included from C:\Users\...\Documents\Arduino\libraries\MPU9250/MPU9250.h:5:0,
from C:\Users\...\Documents\Arduino\prova\prova.ino:1:
C:\Users\...\Documents\Arduino\libraries\MPU9250/MPU9250.h: In instantiation of 'void MPU9250_<WireType>::read_bytes(uint8_t, uint8_t, uint8_t, uint8_t*) [with WireType = TwoWire; uint8_t = unsigned char]':
C:\Users\...\Documents\Arduino\libraries\MPU9250/MPU9250.h:428:19: required from 'void MPU9250_<WireType>::initAK8963() [with WireType = TwoWire]'
C:\Users\...\Documents\Arduino\libraries\MPU9250/MPU9250.h:143:27: required from 'bool MPU9250_<WireType>::setup(uint8_t, const MPU9250Setting&, WireType&) [with WireType = TwoWire; uint8_t = unsigned char]'
C:\Users\...\Documents\Arduino\prova\prova.ino:10:24: required from here
C:\Users\...\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8\libraries\Wire\src/Wire.h:63:12: note: candidate 1: size_t TwoWire::requestFrom(int, int)
size_t requestFrom(int, int);
^~~~~~~~~~~
C:\Users\...\AppData\Local\Arduino15\packages\arduino\hardware\megaavr\1.8.8\libraries\Wire\src/Wire.h:61:12: note: candidate 2: virtual size_t TwoWire::requestFrom(uint8_t, size_t)
size_t requestFrom(uint8_t, size_t);
^~~~~~~~~~~
The library I'm using right now is from "hideakitai" 0.4.8 version.