MPU9250_asukiaaa icon indicating copy to clipboard operation
MPU9250_asukiaaa copied to clipboard

Magnetometer reading error

Open GusakIurii opened this issue 3 years ago • 33 comments

started sensorId: 113 accelX: -0.07 accelY: 0.00 accelZ: -1.02 accelSqrt: 1.02 gyroX: 0.85 gyroY: -1.59 gyroZ: 0.67 Cannot read mag values at 102ms

sensorId: 113 accelX: -0.08 accelY: -0.02 accelZ: -1.01 accelSqrt: 1.02 gyroX: 0.79 gyroY: -1.59 gyroZ: 0.67 Cannot read mag values at 610ms

board MPU9250 MCU borad Loraduino R1.2

I2C connection (A4, A5) Arduino IDE 1.8.4

GusakIurii avatar Mar 05 '21 12:03 GusakIurii

I want you to check these.

  • Are you sure that it is MPU9250 not 6500?
    MPU6500 does not have magnetometer and that kind board sometimes has 6500.
  • Do you call beginMag?
    It is needed to activate magnetometer.

asukiaaa avatar Mar 05 '21 12:03 asukiaaa

  • I am using MPU9250. Here is such
  • Yes, I am doing mySensor.beginMag (); I took the sketch - GetData.ino, no changes.

GusakIurii avatar Mar 05 '21 13:03 GusakIurii

The module sometimes putted MPU6500. I have ever got a MPU6500 module even though the site mentions only MPU9250. Can you see engrave about MP9250 on your chip like this?

It is very difficult to see but this chip is written MP92 on upper line of SPSLA1. IMG_20210305_232205

If yes, I have no idea. Can you try other module?

asukiaaa avatar Mar 05 '21 14:03 asukiaaa

Or MP92 W82L C1.

MP92 W82L C1

GusakIurii avatar Mar 05 '21 14:03 GusakIurii

My sensor works with the library https://github.com/bolderflight/mpu9250-arduino

This library is the only one that works with my hardware! But I would also like to get the coordinates of the direction of the sensor not in the axes, but in the tilt angle, and the second from the Magnetometer as the direction where it is looking. I thought it was implemented in this library, but alas ..

GusakIurii avatar Mar 05 '21 14:03 GusakIurii

Thank you for the photos. Then I'm not sure the reason why.

asukiaaa avatar Mar 05 '21 15:03 asukiaaa

Hi,

I think the mag error comes from an error when reading the high/low bytes, they are switched:

https://github.com/asukiaaa/MPU9250_asukiaaa/blob/b983f4f47694ec7fdcd24ae29fc293fa175c6f46/src/MPU9250_asukiaaa.cpp#L151

vs

https://github.com/asukiaaa/MPU9250_asukiaaa/blob/b983f4f47694ec7fdcd24ae29fc293fa175c6f46/src/MPU9250_asukiaaa.cpp#L221

Nodraak avatar Mar 19 '21 13:03 Nodraak

Same here can't read mag values, same board, one strange thing is that whoamI returns 0x70 and according to datasheet it's a mpu6050, I'm not sure if there is a wat to certify if it's a 9250 or 6050

racs avatar May 18 '21 13:05 racs

My sensor works with the library https://github.com/bolderflight/mpu9250-arduino

This library is the only one that works with my hardware! But I would also like to get the coordinates of the direction of the sensor not in the axes, but in the tilt angle, and the second from the Magnetometer as the direction where it is looking. I thought it was implemented in this library, but alas ..

Did you use it with esp32 only?

sam17012k1 avatar Jun 04 '21 09:06 sam17012k1

I have the same issue on a GY-91 board (contains the MPU9250). Using bolderflight, I read the magnetic sensor data just fine, but with this library, I cannot access it. Reading through the code, it looks like bolderflight uses master mode and reads the magnetic data through the MPU while this library tries to do the bypass and read the AK8963 directly. Unfortunately, I don't know enough right now to understand why that doesn't work.

SebastianHD avatar Jul 24 '21 21:07 SebastianHD

I have the same issue on the esp32 board. surly my sensor is mpu9250. getting the response code is:117, I am reading accelerometer and gyro values, but mag values are not getting, cannot read mag values message on the screen......

narendar-yaga avatar Apr 13 '22 09:04 narendar-yaga

Hi, I tried with an ESP32 and Adafruit itsy bitsy 32u4, and this lib doesn't read magnetometer, I check and MP92 is written on my module. Bolder Flight lib doesn't work at all, it cannot communicate with the IMU. Did anyone figured out a workaround?

izsoandras avatar Apr 28 '22 09:04 izsoandras

I checked and succeeded in reading values with using ESP32-WROOM-32D and platform-espressif32.v4.1.0 (it includes arduino-esp32 v2.0.1).

Can you report with the following information?

  • Environment with you use for building program.
  • Hardware which you use.
  • Result of i2c-scanner. Default device address of MPU9250 is 0x68.

In my case.

  • platform-io 5.2.5 and platform-espressif32 4.1.0
  • ESP32-WROOM-32D
  • Succeeded in finding 0x68 device by i2c-scanner

asukiaaa avatar Apr 29 '22 08:04 asukiaaa

  • Build: arduino IDE 1.8.19 with esp32 by Espressif Systems Version 1.0.6 library
  • Device: ESP-WROOM-32
  • I2C founds the 0x68 address. If I understand right, if I write 00000010 in the 0x37 register, I should be able to reach the magnetometer directly, which is not successful (on another board, with the same chip, according to the engraving, after writing this a 0x0C address shows up on the scan)

The chip on my sensor board is MP92 236LA 1833

izsoandras avatar Apr 29 '22 14:04 izsoandras

@izsoandras where you able to find a solution? I'm having the same issue and also a very similar serial number on the sensor board

marcofariasmx avatar May 30 '22 17:05 marcofariasmx

@marcofariasmx Unfortunately no. After I couldn't reach the magnetometer directly I gave up, because the exams kicked in. Maybe when they are finished I'll try it again.

izsoandras avatar Jun 14 '22 08:06 izsoandras

I tried today and it's no problem on my environment.

My env

  • PlatformIO 6.0.2
  • platform-espressif 4.4.0 (It includes arduino-esp32 2.0.2)
  • ESP-WROOM-32 (IC version 0)

Build: arduino IDE 1.8.19 with esp32 by Espressif Systems Version 1.0.6 library

I suggest you to use newer arduino-esp32. Latest version is 2.0.3.

Device: ESP-WROOM-32

It seems no problem. I checked with using ESP-WROOM-32 (not 32D) which version of IC is 0.

I2C founds the 0x68 address. If I understand right, if I write 00000010 in the 0x37 register, I should be able to reach the magnetometer directly, which is not successful (on another board, with the same chip, according to the engraving, after writing this a 0x0C address shows up on the scan)

No, before that you need to write value to 0x6B register likes https://github.com/asukiaaa/MPU9250_asukiaaa/blob/b983f4f47694ec7fdcd24ae29fc293fa175c6f46/src/MPU9250_asukiaaa.cpp#L116-L122.

asukiaaa avatar Jun 18 '22 04:06 asukiaaa

have the same problem (can't read mag data) sensorId: 112 accelX: 0.23 accelY: 0.03 accelZ: 1.03 accelSqrt: 1.06 gyroX: -8.06 gyroY: 1.95 gyroZ: 0.55 Cannot read mag values 2 at 3081ms

I use GY91 MPU9250+BMP280 10DOF Has anybody fixed this problem?

Screen Shot 2023-02-25 at 15 37 35

Overff avatar Feb 25 '23 12:02 Overff

@Overff What IC (Arduino) do you use?

asukiaaa avatar Feb 25 '23 12:02 asukiaaa

@Overff What IC (Arduino) do you use?

Actually i use Teensy3.6 (like arduino) port A4, A5

I2CScan: --- Scan started --- I2C device found at address 0x68 ! --- Scan finished ---

1

Overff avatar Feb 25 '23 13:02 Overff

My teensy3.6 could read mag value. To read the mag values, calling beginMag is required. Do you try restarting teensy 3.6 with connecting to MPU9250? original_7fe8ad07-7030-4e12-abd8-5bc1bd976ee0_IMG_20230225_235232

I add function to call beginMag again when failing to get mag values. https://github.com/asukiaaa/MPU9250_asukiaaa/commit/c6882aecf94d3fd07800103aa5be197686e707ee

asukiaaa avatar Feb 25 '23 14:02 asukiaaa

Thank you for support. I have realized that your MPU is differ than mine.. Probably my has another register with mag data and so on. Could you provide some advice what should i need research to find out the problem?

Overff avatar Feb 25 '23 15:02 Overff

Can you see MP92 on your sensor IC as I mentioned on comment Mar 5, 2021? https://github.com/asukiaaa/MPU9250_asukiaaa/issues/22#issuecomment-791453750 Sometimes board has MPU6500 which does not have magnetometer.

asukiaaa avatar Feb 25 '23 15:02 asukiaaa

Checked it. Ii says: mp92/U601A1/2148 o_O

Overff avatar Feb 25 '23 15:02 Overff

Thank you for the information. It seems mpu9250. I'm not sure the reason of this problem.

asukiaaa avatar Feb 25 '23 15:02 asukiaaa

thank you any way!

Overff avatar Feb 25 '23 16:02 Overff

I have the same sensor board as Overff "GY91 MPU9250+BMP280" and I also have the "MP92/U601A1/2148" installed on this board. Acceleration values and gyro values can be read out, but no values come from the magnetometer.

Wollo89 avatar Mar 21 '23 17:03 Wollo89

had anyone got any solution to read values come from the magnetometer ? written "mp92" on the sensor ic . but when i test with the program it shows 0x70 and MPU6500 .

crackplatoonbd avatar Apr 05 '23 11:04 crackplatoonbd

Hi there! fyi, Finally I coped with the problem. The problem is - fake board. My mpu-9250/6500 was a fake (. So, I've changed the board and problem dissipated.

I2CScanner result (normal board): --- Scan started --- I2C device found at address 0x0C ! I2C device found at address 0x68 ! --- Scan finished ---

I2CScanner result (fake board): --- Scan started --- I2C device found at address 0x68 ! --- Scan finished ---

Actually they look the same. IMG_6272

Overff avatar May 20 '23 09:05 Overff

Hi there! fyi, Finally I coped with the problem. The problem is - fake board. My mpu-9250/6500 was a fake (. So, I've changed the board and problem dissipated.

I2CScanner result (normal board): --- Scan started --- I2C device found at address 0x0C ! I2C device found at address 0x68 ! --- Scan finished ---

I2CScanner result (fake board): --- Scan started --- I2C device found at address 0x68 ! --- Scan finished ---

Actually they look the same. IMG_6272

I don’t understand how the I2C scanner showed you the address of the magnetometer sensor 0x0C if this is an internal address. The external address is 0x68, and the magnetometer sensor cannot be directly "reached out". You are clearly lying.

brightproject avatar Jul 12 '23 05:07 brightproject