MPU9250

Here we can discuss about the problem found
Post Reply
SlobaNS
Posts: 4
Joined: Wed Sep 20, 2023 7:01 am

MPU9250

Post by SlobaNS »

I played around with the I2C devices and everything worked great, but the 9-DOF sensor MPU9250 doesn't work for me. I made a small test program so I will try to explain the problem with my test example:

CODE:
'MPU9250 test
i2c.Setup 21,22, 400000 '400000 set the I2C to max speed
'checking I2C connection
i2c.begin &h68
if i2c.end = 0 then
wlog "I2C Address &h68 Found "
endif
ret = MPU9250.SETUP(&h68)
wlog "MPU9250.SETUP(&h68) =", ret

In the first part of the program, I initialize the I2C communication, the program recognizes the address of the sensor (H68), but the MPU9250.SETUP function responds with 0, as if the sensor was not initialized.

WLOG answer:
I2C Address &h68 Found
MPU9250.SETUP(&h68) = 0

In the next line, I successfully read the temperature from the sensor, regardless of the response of the function MPU9250.SETUP:

CODE:
wlog "Temperature", str$(MPU9250.TEMP, "%3.1f") ; "°C"

WLOG answer:
Temperature 38.8°C

And then I read the vector with the all measurement results:

CODE:
Dim vect(10) 'dimension the array
ret=MPU9250.VECTOR(vect())
wlog "MPU9250.VECTOR() =", ret
WLOG "AX, AY, AZ = ", vect(0), " ", vect(1), " ", vect(2)

WLOG answer:
MPU9250.VECTOR() = 1
AX, AY, AZ = -0 -0 -0

So the program confirms reading the result (status bit of the function MPU9250.VECTOR is 1), but the vector is empty, all zeros.

Immediately after that in the same program I directly read the acceleration result registers (reg 59 to 64) successfully!

CODE:
WLOG "AX ",I2C.READREGBYTE (&h68, 59)*256+I2C.READREGBYTE (&h68, 60)
WLOG "AY ",I2C.READREGBYTE (&h68, 61)*256+I2C.READREGBYTE (&h68, 62)
WLOG "AZ ",I2C.READREGBYTE (&h68, 63)*256+I2C.READREGBYTE (&h68, 64)

WLOG answer:
AX 61712
AY 51048
AZ 62604

So I really don't know if it's my fault, or it's a bug in the interpreter function?
bugs
Posts: 143
Joined: Mon Feb 08, 2021 10:10 pm
Location: Scotland
Has thanked: 47 times
Been thanked: 51 times

Re: MPU9250

Post by bugs »

Possibly a fake MPU9250?
See this previous thread:-[Local Link Removed for Guests]
SlobaNS
Posts: 4
Joined: Wed Sep 20, 2023 7:01 am

Re: MPU9250

Post by SlobaNS »

Thanks, this thread is useful. I'm surprised I didn't find her sooner. My module looks identical to Zim's in the photo, maybe it's not the right one. The chip has the mark 92 on it, but I don't know which magnetometer is built into it.

The basic sketch that I wrote works, i can read acceleration and gyro data and that's enough for me until now. But I'm sure reading the results with the built-in function would be faster than reading directly from the basic sketch. Functions are written in C, right?
bugs
Posts: 143
Joined: Mon Feb 08, 2021 10:10 pm
Location: Scotland
Has thanked: 47 times
Been thanked: 51 times

Re: MPU9250

Post by bugs »

Sorry - I have no experience with the MPU9250 and do not have one to play with.

What I normally do with a new (to me) chip that does not play with Annex - is to hook it up to an Arduino - usually a UNO and try all the library examples.
If all work then most likely the chip is ok so I then program an ESP with Arduino and test for compatability.
Finally back again to Annex with known good/bad chip and its function tested with an ESP.
Post Reply