Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Magnetometer reading error #22

Open
GusakIurii opened this issue Mar 5, 2021 · 33 comments
Open

Magnetometer reading error #22

GusakIurii opened this issue Mar 5, 2021 · 33 comments

Comments

@GusakIurii
Copy link

GusakIurii commented Mar 5, 2021

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

@asukiaaa
Copy link
Owner

asukiaaa commented Mar 5, 2021

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.

@GusakIurii
Copy link
Author

GusakIurii commented Mar 5, 2021

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

@asukiaaa
Copy link
Owner

asukiaaa commented Mar 5, 2021

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?

@GusakIurii
Copy link
Author

GusakIurii commented Mar 5, 2021

Or MP92 W82L C1.

MP92 W82L C1

@GusakIurii
Copy link
Author

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 ..

@asukiaaa
Copy link
Owner

asukiaaa commented Mar 5, 2021

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

@Nodraak
Copy link

Nodraak commented Mar 19, 2021

Hi,

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

return adjustMagValue(magGet(1, 0), magXAdjust) + magXOffset;

vs

return gyroGet(0, 1);

@racs
Copy link

racs commented May 18, 2021

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

@sam17012k1
Copy link

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?

@SebastianHD
Copy link

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.

@narendar-yaga
Copy link

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......

@izsoandras
Copy link

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?

@asukiaaa
Copy link
Owner

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

@izsoandras
Copy link

izsoandras commented Apr 29, 2022

  • 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

@marcofariasmx
Copy link

@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

@izsoandras
Copy link

@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.

@asukiaaa
Copy link
Owner

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

void MPU9250_asukiaaa::magWakeup() {
unsigned char bits;
i2cRead(address, MPU9250_ADDR_PWR_MGMT_1, 1, &bits);
bits &= ~B01110000; // Turn off SLEEP, STANDBY, CYCLE
i2cWriteByte(address, MPU9250_ADDR_PWR_MGMT_1, bits);
delay(10);
}
.

@Overff
Copy link

Overff commented Feb 25, 2023

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

@asukiaaa
Copy link
Owner

@Overff
What IC (Arduino) do you use?

@Overff
Copy link

Overff commented Feb 25, 2023

@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

@asukiaaa
Copy link
Owner

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.
c6882ae

@Overff
Copy link

Overff commented Feb 25, 2023

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?

@asukiaaa
Copy link
Owner

asukiaaa commented Feb 25, 2023

Can you see MP92 on your sensor IC as I mentioned on comment Mar 5, 2021?
#22 (comment)
Sometimes board has MPU6500 which does not have magnetometer.

@Overff
Copy link

Overff commented Feb 25, 2023

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

@asukiaaa
Copy link
Owner

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

@Overff
Copy link

Overff commented Feb 25, 2023

thank you any way!

@Wollo89
Copy link

Wollo89 commented Mar 21, 2023

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.

@crackplatoonbd
Copy link

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 .

@Overff
Copy link

Overff commented May 20, 2023

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

@brightproject
Copy link

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.

@antdavisonNZ
Copy link

https://invensense.tdk.com/wp-content/uploads/2015/02/PS-MPU-9250A-01-v1.1.pdf
page 24: Pass-Through mode is also used to access the AK8963 magnetometer directly from the host. In this
configuration the slave address for the AK8963 is 0X0C or 12 decimal.

@antdavisonNZ
Copy link

I also purchased 5 gy-91s and they were also marked as "MP92/U601A1/2148"
All 5 were fake with a WHOAMI identifaction as 0x70, ie an mpu6500, 4 are pictured below, the fifth was already soldered to its carrier PCB and didnt scan well. The community needs to get together to identify and warn is members as to which marked 9250/5s are fake, and what behaviour to look for

fakeGY-91
fake-6500not9250-55a
fake-6500not9250-55b

AliExpress Item : https://www.aliexpress.com/item/32654511799.html

AliExpress Vendor : https://www.aliexpress.com/store/403088
Far East Electronics
​Contact Person
Mr. Mars Wu
Telephone
86-755-82814528
Fax Number
86-755-82814200
Address
35/F World Trade Center, Causeway Bay, Hong Kong

@antdavisonNZ
Copy link

I re-purchased another 5 GY-91s which were genuine mp9250s (WHOAMI 0x71) with correctly working barometers, the previous purchase detailed above only 2 of the 5 BMP280s functioned correctly as well as having fake IMUs (WHOAMI 0x70)/
The genuine ones are at
https://www.aliexpress.com/item/32591987418.html
webOrders

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests