Sorry for this beginner question T.T, but I was trying to learn how to use an MPU9250 imu on youtube and downloaded his code and installed the same library from library manager. But when I compiled, the compiler gives this error:
#include <mpu9250.h>
// Code by Tasty Tech Harbour
// Blog - www.tastytechharbour.com
// Personal website - www.srujancmutt.com
// Contact - contact@srujancmutt.com
// Youtube Channel - https://www.youtube.com/c/TastyTechHarbour/
// The below code is for I2C communication with the Arduino.
// Links to the products used in this projects are mentioned in my blog.
#include <Wire.h>
mpu9250 IMU (Wire , 0x68); // MPU9250 is a class and "IMU" is a object, we need to pass parameter to the object "IMU". wire is used for I2C communication,
// second parameter is for I2C address, we left the ADO pin unconnected so its set to low, 0x68 is address,
// if it was high then the address is 0x69
void setup() { // put your setup code here, to run once:
Serial.begin(9600); // initialize the serial monitor
IMU.begin(); // Initialize the IMU object
}
void loop() {
// put your main code here, to run repeatedly:
IMU.readSensor();
//Accelerometer data code
Serial.print("Accelerometer X axis: ");
Serial.print(IMU.getAccelX_mss(), 3); // to get the accelerometer value from the data buffer in the X direction, these values are in meter per second square
Serial.print(" Accelerometer Y axis: ");
Serial.print(IMU.getAccelY_mss(), 3);
Serial.print(" Accelerometer Z axis: ");
Serial.println(IMU.getAccelZ_mss(), 3);
//Gyroscope data code
Serial.print("Gyroscope X axis(radians): ");
Serial.print(IMU.getGyroX_rads(), 3); // gets the gyroscope value from the data buffer in the X direction, these vavlues are in radians per second
Serial.print(" Gyroscope Y axis(radians): ");
Serial.print(IMU.getGyroY_rads(), 3);
Serial.print(" Gyroscope Z axis(radians): ");
Serial.println(IMU.getGyroZ_rads(), 3);
//Magnetometer data code
Serial.print("Magnetometer X axis(MicroTesla): ");
Serial.print(IMU.getMagX_uT(), 3); //gets the magnetometer value from the data buffer in the X direction, these are in microtesla
Serial.print(" Magnetometer Y axis(MicroTesla): ");
Serial.print(IMU.getMagY_uT(), 3);
Serial.print(" Magnetometer Z axis(MicroTesla): ");
Serial.println(IMU.getMagZ_uT(), 3);
//Temperature reading
Serial.print("Temperature: ");
Serial.println(IMU.getTemperature_C(), 2); // gets the temperature value from the data buffer and returns it in units of C
Serial.print("*********** Next buffer data *****************");
Serial.println(" ");
Serial.println(" ");
Serial.println(" ");
Serial.println(" ");
delay(2000);
}
In file included from C:\Users\chankyaw\Documents\Arduino\ChanMotors\mpu9250\mpu9250.ino:1:0:
C:\Users\chankyaw\Documents\Arduino\libraries\Bolder_Flight_Systems_MPU9250\src/mpu9250.h:36:10: fatal error: cstddef: No such file or directory
#include <cstddef>
^~~~~~~~~
compilation terminated.
exit status 1
Compilation error: exit status 1
Can someone help me with what it means and what I can do to solve this issue? Any cmt would be appreciated.
Edit:
here is the .h file that i found. It does contain
...
#include <cstddef>
#include <cstdint>
#include "eigen.h" // NOLINT
#include "Eigen/Dense"
...
so probably not having these are the problem ? T.T, but I don't know how to solve this. Pls help ![]()
mpu9250.cpp (20.4 KB)
mpu9250.h (10.0 KB)