Correct temperature scale formula for MPU6500

Hi,

I have a few chinese breakout boards with MPU6050 and 6500 chips on them.

It seems that Ivensense use two different scaling formulae to get form the sensor data to a temperature in celcius. Neither of which give credible temperature out values.

They are typically 5-10 deg C either side of ambient room temp. I'm aware this is chip temp but I doubt the current case I have on the bench showing 7 deg C LESS than ambient is the chip temp. They are somewhat near RT, and the rest of the data is good, so I rule out comms failure or incorrect programming of the interface.

This seems to be persistent problem and I have found two formulae on line. Neither of which seem to be physically credible.

Has anyone managed to get this to work correctly or should I regard this as a largely worthless feature?

I should also note that I do not know the origin of the actual chips. One is marked IVENSENSE MPU-6050, so I'm guessing it's legit, the other seems like markings may have been osbcured. In any case it's not too legible, so it could be a knock off chip, not Ivensense devices. It register structure and whoami reg suggest 6500.

TIA.

If it is of any help, this is what I see from the datasheet:
Temperature = ((TEMP_OUT – RoomTemp_Offset)/Temp_Sensitivity) + 21degC
where RoomTemp_Offset = 0 and Temp_Sensitivity = 333.87

So
Temperature = (TEMP_OUT / 333.87) + 21.0

thanks,

I have rev 2.1 of the 6500 data sheet which gives that formula but I do not see where gives RoomTemp_Offset = 0. If that is the case what is the point of that parameter? That was part of my confusion.

What do you have for 6050 ?

I have rev 2.1 of the 6500 data sheet which gives that formula but I do not see where gives RoomTemp_Offset = 0.

from https://www.hestore.hu/prod_getfile.php?id=8301

That would be


Temperature = (TEMP_OUT - 521) / 340.0 + 35.0


update: updated the formula.


The formula above is incorrect (see discussion below) the correct version is

Temperature = (TEMP_OUT + 521) / 340.0 + 35.0

What do you actually want to use the temperature reading for?

The MPU's temperature sensor isn't intended to be an accurate ambient temperature sensor. It's primarily useful for tracking the die temperature and temperature-dependent behaviour of the IMU. So even if you get the conversion formula right, it may not give you the ambient temperature accuracy you're looking for.

If you need actual ambient temperature, use a proper temperature sensor such as a DS18B20 instead.

Thank you for answering @robtillaart.
I was off the air for a while

"Temperature = (TEMP_OUT - 521) / 340.0 + 35.0"

Thanks Rob, for 6050 I was using this which is the same:

(float)temp / 340.0 + 36.53

[EDIT] well not quite the same the offset is neg., so I add it to correct for the offset.

Re. 6500: Now, I understand the room temp offset. It is not an offset, it is the temperature with zero offset, so it is indeed not needed in the calculation.

That won't get my 6050 any nearer and I dumped the 6500 which was junk anyway.

Thanks for the help. At least I know I have the right figures now.

Hang on 6050 spec. sheet says at 35deg C it will output -521 .

(T-35)*340=-521 LSB = temp_out

(temp_out +521)/340.0+35 = Temp / deg C

aka: (temp_out )/340.0+36.53 = Temp / deg C

6500: at 21deg C it will output 0x0000 .

temp_out / 333.87f + 21.f

Make sense?

Did you see post #5?

Did you see post #1 ?

In my opinion it says offset at 35'C is -521. So what robtillart posted should be correct.
But is it valid offset at 15'C, I have no idea.

Thanks for your reply.

Linearity is quite good : +/- LSB -40 to 85 C. So this should be the const term of a linear fit to real data.

So how do we interpret "offset". Offset from what? I can only understand that as offset from zero.

If I want to correct an offset of 100, I would expect to subtract 100.

If I want to correct an offset of -100, I would expect to add 100.

If there is another way to understand that, can someone explain the logic?

Thanks.

Maybe this is an temp_out = m*T+c situation. Sensitivity is m (LSB/deg.C), c (LSB) is "offset".

Still looks the same to me.

That's the point, it's not 100% clear.
The table says: Offset = āˆ’521 LSB @ 35°C

If we assume it means: Traw(35'C) = -521
then
T = (Traw - (-521)) / 340 +35
T= Traw / 340 + 36.532

That is correct and as I pointed out the offset for the 6500 is zero. See post #2

Thanks but that does not really weigh either way. Since the 6500 "offset" is zero : 0= -0

The confusion arises with the finite "offset" is -521

Maybe the ambiguity is why the 6500 doc. gives the temp at which offset is zero.

How do you interpret -521 , do I add it or subtract it, and why?

It seems I need to subtract the offset, hence add 521.

I don't see why, it's just a number like 0 which is also finite.

0 is "just a number" and it is finite (or rather infinitely small) but it does not matter whether you add or subtract it. In fact as I pointed out it does not even need to be in the calculation.

Yes it does. The formula has a parameter called RoomTemp_Offset and you need to know what that is whether it's 0 or not does not matter.

If I subtract -521 , I add 521. So you agree with my reading that the formula needs to be:

' (temp_out )/340.0+36.53 = Temp / deg C'

For the 6500 or the 6050?