MPU 9250 / 6050 boards no readings (reading 0,0,0)

Hi, I cannot get readings from the MPU 9250 and 6050 boards. I have I2C wired correctly as the I2C scanner can find the MPU 9250 and the 6050 when I connect them. (Note that I'm only using 1 board at a time. So Im either using the MPU9250 or the MPU6050, not both at the same time). I have the board powered with 3.3V with the SDA and SCL pins connected to ESP32 D21 and D22 pins. Im using the ESP32 as my microcontroller.

I've tried using the libraries "Bolder Flight Systems MPU9250" by Brian Taylor and the "MPU9250" By Hideakitai for the MPU9250 board. And for the MPU6050 I've tried "Adafruit MPU6050" and "MPU6050" by Electronic Cats.

The example code from the "MPU9250" library called "Simple_With_Calibration" says in the serial monitor "MPU connection failed. Please check your connection with connection_check example".
When using the "Connection_Check" example code it shows this in the serial monitor

Searching for i2c devices...
Found 1 I2C devices
I2C addresses are: 0x68
I2C address 0x68 is not MPU series
WHO_AM_I is 75
Please use correct device
AK8963 (Magnetometer) was not found

The board I have connected is an MPU9250 so I don't know why it says it's not an MPU series board.

The MPU6050 libraries just read 0,0,0 for both the accelerometer and gyro. And the example code from the "Bolder Flight Systems MPU9250" Library called "I2C" gives me a compilation error.

In file included from C:\Users\inahs\AppData\Local\Temp.arduinoIDE-unsaved2023417-19860-1715ngi.pnlq\i2c\i2c.ino:26:0:
C:\Users\inahs\Documents\Arduino\libraries\Bolder_Flight_Systems_MPU9250\src/mpu9250.h:36:10: fatal error: cstddef: No such file or directory
#include
^~~~~~~~~
compilation terminated.

exit status 1

Compilation error: exit status 1

I have tried to do this with both an Arduino UNO and an ESP32 with both the MPU9250 and the MPU6050. I've also tried this with another MPU6050 and the results are the same every time. If anyone has any ideas I would greatly appreciate it.

Just saying for the Arduino UNO I wired SDA and SCL pins to A4 and A5 and again, the MPU boards were able to show up in an I2C scanner.

From which library? Whichever library it is, I strongly suspect that it does not take the 9050 into account.

I've moved your topic to a more suitable location on the forum.

just tested MPU6050 on a ESP32 using File>Examples>Adafruit_MPU6050>basic_readings worked OK
serial monitor displays

Adafruit MPU6050 test!
MPU6050 Found!
Accelerometer range set to: +-8G
Gyro range set to: +- 500 deg/s
Filter bandwidth set to: 21 Hz

Acceleration X: 0.04, Y: 0.39, Z: 8.35 m/s^2
Rotation X: 0.15, Y: 0.03, Z: 0.00 rad/s
Temperature: 22.04 degC

Acceleration X: 0.42, Y: 2.15, Z: 7.68 m/s^2
Rotation X: 0.07, Y: -0.65, Z: -0.07 rad/s
Temperature: 22.16 degC

Acceleration X: -3.13, Y: 4.82, Z: 5.66 m/s^2
Rotation X: -0.51, Y: -0.52, Z: -0.24 rad/s
Temperature: 22.23 degC

Acceleration X: 0.91, Y: -0.04, Z: 9.27 m/s^2
Rotation X: 1.01, Y: 0.07, Z: 0.09 rad/s
Temperature: 22.27 degC

Acceleration X: 0.01, Y: -0.51, Z: 8.30 m/s^2
Rotation X: 0.15, Y: 0.03, Z: 0.01 rad/s
Temperature: 22.31 degC

Acceleration X: 0.03, Y: -0.51, Z: 8.31 m/s^2
Rotation X: 0.15, Y: 0.03, Z: 0.01 rad/s
Temperature: 22.35 degC

Acceleration X: 0.02, Y: -0.51, Z: 8.30 m/s^2
Rotation X: 0.15, Y: 0.03, Z: 0.00 rad/s
Temperature: 22.37 degC

tested a MPU9250 using MPU9250_asukiaaa running File>Examples>PU9250_asukiaaa>GetData

cannot read mag so call begin again
Cannot read mag values 2
at 789ms

sensorId: 116 accelX: -0.92 accelY: -0.02 accelZ: -0.16 accelSqrt: 0.93 gyroX: 9.52 gyroY: 85.14 gyroZ: -7.39
cannot read mag so call begin again
Cannot read mag values 2
at 1364ms

sensorId: 116 accelX: -0.88 accelY: -0.01 accelZ: 0.25 accelSqrt: 0.92 gyroX: 31.92 gyroY: -297.12 gyroZ: 44.62
cannot read mag so call begin again
Cannot read mag values 2
at 1939ms

sensorId: 116 accelX: 0.42 accelY: -0.60 accelZ: -1.08 accelSqrt: 1.30 gyroX: -25.88 gyroY: -1.22 gyroZ: -13.06
cannot read mag so call begin again
Cannot read mag values 2
at 2514ms

sensorId: 116 accelX: 0.28 accelY: -0.67 accelZ: -0.40 accelSqrt: 0.83 gyroX: -28.63 gyroY: 77.03 gyroZ: -37.23
cannot read mag so call begin again
Cannot read mag values 2
at 3089ms

appears to be having problem read mag data

module labled MPU-9250/mpu6500
if I run File>Examples>Bolder_Flight_Systems_InvenSense_IMU>Arduino>impu9250>i2c I get

Error initializing communication with IMU

if I run File>Examples>Bolder_Flight_Systems_InvenSense_IMU>Arduino>mpu6500>i2c

1	-6.94	-25.42	2.60	-0.01	-0.02	0.02	119.04
1	-6.24	-23.77	3.10	-0.02	-0.02	0.02	119.04
1	-4.73	-24.69	3.23	-0.02	-0.02	0.01	119.04
1	-4.73	-24.74	3.17	-0.01	-0.02	0.02	119.04
1	-4.75	-24.78	3.24	-0.02	-0.02	0.01	119.04
1	-4.65	-24.72	3.18	-0.01	-0.02	0.02	119.04
1	-8.50	-31.06	1.55	-0.02	-0.02	0.02	119.04
1	-13.48	-21.20	1.64	-0.02	-0.02	0.02	119.04
1	-15.46	-18.48	-0.96	-0.02	-0.02	0.02	119.04
1	-10.50	-11.50	-2.30	-0.02	-0.02	0.02	119.04
1	0.95	-10.57	3.42	-0.02	-0.02	0.02	119.04
1	0.25	-34.97	-3.89	-0.02	-0.02	0.01	119.04
1	-1.47	-32.12	-5.63	-0.01	-0.02	0.02	119.04
1	-0.14	-34.45	-2.45	-0.02	-0.02	0.02	119.04
1	-3.78	-30.50	1.97	-0.02	-0.02	0.02	119.04
1	-8.34	-22.78	2.45	-0.02	-0.02	0.02	119.04

I tried the MPU6050 with the Adafruit_MPU6050>basic_readings and I got this.

Adafruit MPU6050 test!
MPU6050 Found!
Accelerometer range set to: +-8G
Gyro range set to: +- 500 deg/s
Filter bandwidth set to: 21 Hz
Acceleration X: 0.00, Y: 0.00, Z: 0.00 m/s^2
Rotation X: 0.00, Y: 0.00, Z: 0.00 rad/s
Temperature: 36.53 degC

So it connects but still no readings (I let it run for a little bit and it still gave zeros).

I tried the MPU9250 using the MPU9250_asukiaaa library you gave me using the save GetData example code and I got this.

sensorId: 117
accelX: 0.02
accelY: -0.14
accelZ: 1.21
accelSqrt: 1.22
gyroX: 6.84
gyroY: -4.58
gyroZ: -0.73
cannot read mag so call begin again
Cannot read mag values 2
at 21469ms

sensorId: 117
accelX: 0.01
accelY: -0.14
accelZ: 1.21
accelSqrt: 1.22
gyroX: 6.59
gyroY: -4.39
gyroZ: -0.67
cannot read mag so call begin again
Cannot read mag values 2

From what it looks like it seems that the readings I'm getting are accurate though I need to translate the gyro from rad/s to degrees.

Can I know what board you have selected in the board manager for the ESP32?
Also is there a way to calibrate the gyro using the MPU9250_asukiaaa library since that seems to be the only library that has worked for me so far?

Thanks.

I used ESP32 Dev Module
have a look at the LSM9DS1_sensor 9-axis iNEMO inertial module
used it in a couple of industrial projects
works with ESP32 OK, e.g.

sample time 20mSec
samples/second 50
Acceleration X: -1.61 m/s^2 Y:   0.51 m/s^2 Z:  9.63 m/s^2
magnetic X:  0.13 m/s^2 Y:   0.10 m/s^2 Z: -0.07 m/s^2
Gyroscope X:  0.03 m/s^2 Y:   1.89 m/s^2 Z: -1.83 m/s^2

samples/second 50
Acceleration X: -1.49 m/s^2 Y:   0.53 m/s^2 Z:  9.94 m/s^2
magnetic X:  0.12 m/s^2 Y:   0.11 m/s^2 Z: -0.09 m/s^2
Gyroscope X: -0.01 m/s^2 Y:   2.69 m/s^2 Z: -3.82 m/s^2

samples/second 50
Acceleration X: -0.38 m/s^2 Y:   0.49 m/s^2 Z: 11.27 m/s^2
magnetic X:  0.20 m/s^2 Y:   0.11 m/s^2 Z: -0.06 m/s^2
Gyroscope X: -19.88 m/s^2 Y:  51.30 m/s^2 Z:  1.26 m/s^2

samples/second 50
Acceleration X:  2.88 m/s^2 Y:   1.13 m/s^2 Z: 10.53 m/s^2
magnetic X:  0.29 m/s^2 Y:   0.09 m/s^2 Z: -0.07 m/s^2
Gyroscope X: 21.59 m/s^2 Y:  65.76 m/s^2 Z: 12.22 m/s^2

samples/second 50
Acceleration X:  6.50 m/s^2 Y:  -2.93 m/s^2 Z:  5.15 m/s^2
magnetic X:  0.47 m/s^2 Y:   0.18 m/s^2 Z:  0.18 m/s^2
Gyroscope X: 27.59 m/s^2 Y:   8.48 m/s^2 Z: -36.57 m/s^2

samples/second 50
Acceleration X:  7.57 m/s^2 Y:  -3.69 m/s^2 Z:  6.93 m/s^2
magnetic X:  0.46 m/s^2 Y:   0.23 m/s^2 Z:  0.27 m/s^2
Gyroscope X: 14.60 m/s^2 Y:   1.06 m/s^2 Z: -4.59 m/s^2

samples/second 50
Acceleration X:  7.25 m/s^2 Y:   4.98 m/s^2 Z: -3.14 m/s^2
magnetic X:  0.44 m/s^2 Y:  -0.22 m/s^2 Z:  0.63 m/s^2
Gyroscope X: 33.10 m/s^2 Y:   6.66 m/s^2 Z: 16.22 m/s^2

samples/second 50
Acceleration X:  0.85 m/s^2 Y:  10.93 m/s^2 Z: -1.49 m/s^2
magnetic X:  0.18 m/s^2 Y:  -0.42 m/s^2 Z:  0.65 m/s^2
Gyroscope X: -20.41 m/s^2 Y:  26.28 m/s^2 Z: 25.12 m/s^2

samples/second 50
Acceleration X: -0.21 m/s^2 Y:   7.99 m/s^2 Z: -6.45 m/s^2
magnetic X:  0.06 m/s^2 Y:  -0.22 m/s^2 Z:  0.80 m/s^2
Gyroscope X: -8.29 m/s^2 Y:   7.06 m/s^2 Z: -18.60 m/s^2

samples/second 50
Acceleration X: -0.55 m/s^2 Y:   4.26 m/s^2 Z: -7.00 m/s^2
magnetic X:  0.25 m/s^2 Y:  -0.20 m/s^2 Z:  0.78 m/s^2
Gyroscope X: -5.23 m/s^2 Y:  -42.31 m/s^2 Z: -92.40 m/s^2

samples/second 50
Acceleration X:  8.72 m/s^2 Y:  -0.72 m/s^2 Z:  6.45 m/s^2
magnetic X:  0.53 m/s^2 Y:   0.06 m/s^2 Z:  0.25 m/s^2
Gyroscope X: 43.16 m/s^2 Y:  -83.26 m/s^2 Z: -38.61 m/s^2

samples/second 50
Acceleration X: -2.53 m/s^2 Y:  -3.84 m/s^2 Z:  8.56 m/s^2
magnetic X:  0.20 m/s^2 Y:   0.18 m/s^2 Z: -0.06 m/s^2
Gyroscope X: -33.01 m/s^2 Y:  87.85 m/s^2 Z: -13.26 m/s^2

Sorry for the very late reply but the "MPU9250_asukiaaa" library worked for me. I don't know why but that's the only library that worked for me. Either way, it works now, Thanks!