So basically, I have a mpu-9250 from which I intend to get the real-time data. I don't know what the problem is with the code, I have installed the necessary libraries ( I think)
Here is the code for the same
#include <mpu9250.h>
#include <Wire.h>
// an MPU9250 object with the MPU-9250 sensor on I2C bus 0 with address 0x68
MPU9250 IMU(Wire, 0x68);
int status;
void setup() {
// serial to display data
Serial.begin(115200);
while (!Serial) {}
// start communication with IMU
status = IMU.begin();
if (status < 0) {
Serial.println("IMU initialization unsuccessful");
Serial.println("Check IMU wiring or try cycling power");
Serial.print("Status: ");
Serial.println(status);
while (1) {}
}
}
void loop() {
// read the sensor
IMU.readSensor();
// display the data
//accelerometer readings
Serial.print("Accel X axis reading: ");
Serial.print(IMU.getAccelX_mss(), 6);
Serial.print(" Accel Y axis reading: ");
Serial.print(IMU.getAccelY_mss(), 6);
Serial.print(" Accel Z axis reading: ");
Serial.println(IMU.getAccelZ_mss(), 6);
//gyroscope reading
Serial.print("Gyro X axis reading: ");
Serial.print(IMU.getGyroX_rads(), 6);
Serial.print(" Gyro Y axis reading: ");
Serial.print(IMU.getGyroY_rads(), 6);
Serial.print(" Gyro Z axis reading: ");
Serial.println(IMU.getGyroZ_rads(), 6);
//magnetometer readings
Serial.print("Magnetometer X axis reading: ");
Serial.print(IMU.getMagX_uT(), 6);
Serial.print(" Magnetometer Y axis reading: ");
Serial.print(IMU.getMagY_uT(), 6);
Serial.print(" Magnetometer Z axis reading: ");
Serial.println(IMU.getMagZ_uT(), 6);
//temp sensor readings
Serial.print("Temp sensor readings: ");
Serial.println(IMU.getTemperature_C(), 6);
delay(100);
}
Here is the full error message -
Arduino: 1.8.19 (Windows Store 1.8.57.0) (Windows 10), Board: "Arduino Nano, ATmega328P"
In file included from C:\Users\adity\OneDrive\Documents\Arduino\arc_tutorial\arc_tutorial.ino:1:0:
C:\Users\adity\OneDrive\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
Error compiling for board Arduino Nano.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Of course there is. Not the code you wrote. The error message tells you exactly where the line is. Delete that line and then post the updated error message. If there's some other reference to that same library, the error message might look similar at first glance.
hi, thanks for pointing out, I had to delete many #include directories in the location specified for it to not give an error regarding that. Even then I got this error.
Appreciate the help
Arduino: 1.8.19 (Windows Store 1.8.57.0) (Windows 10), Board: "Arduino Nano, ATmega328P"
arc_tutorial:6:1: error: 'MPU9250' does not name a type
MPU9250 IMU(Wire, 0x68);
^~~~~~~
C:\Users\adity\OneDrive\Documents\Arduino\arc_tutorial\arc_tutorial.ino: In function 'void setup()':
arc_tutorial:15:12: error: 'IMU' was not declared in this scope
status = IMU.begin();
^~~
arc_tutorial:22:3: error: expected primary-expression before '}' token
}
^
C:\Users\adity\OneDrive\Documents\Arduino\arc_tutorial\arc_tutorial.ino: In function 'void loop()':
arc_tutorial:27:3: error: 'IMU' was not declared in this scope
IMU.readSensor();
^~~
exit status 1
'MPU9250' does not name a type
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
You have gone too far. I suggested you delete one line of code and share the updated error messages. You seem to have gone crazy with an axe. Now you are deleting entire directories?
Hi, no. I deleted one of them each time and every time for the same error: for example - " fatal error: Eigen/dense: No such file or directory".
So I kept deleting them one at a time until there was no such error generated.
If you still wish for me to give you the error only after deleting just the cstddef one, I can do that
what is odd with my setup if I may ask? also I had to give space between #include< cstddef> else it was not showing up in the post.
I installed the official library that pops up in the library manager when you search for mpu 9250 in the search bar, if that helps
Yeah, I did and installed the library recommended by them. It's strange because the library then gives no error for the code given in their GitHub examples but does so for this code, which I presume to be due to the different syntaxes.
Also weird that the library given by the App officially itself causes errors.
I needed one more help, in the library recommended by @sterretje how do I find out what the commands for the library are? I looked up in the Datasheet and register maps and found them quite confusing
It's the same library as that installed via the library manager, just a newer version. Look in the GitHub README and source code for the available functions.
I think the problem may be that the author hasn't made any official Releases: