1

I'm using MPU 6050 and there's a thermometer onboard. However, I looked through the chip set data sheets but could not find the instruction for temperature sensing.

Could you tell me how to calibrate the data string from the two address started from 0x41?

1 Answer 1

2

The temperature sensor is likely included to keep the gyroscope and accelerometer better calibrated over the specified temperature range. The temperature may not be the ambient temperature should the chip warm up.

The temperature sensor specifications are in section 6.3 on page 14 of the specification sheet indirectly pointed to in the question.

TEMPERATURE SENSOR 
Range -40 to +85°C
Sensitivity Untrimmed 340 LSB/ºC
Temperature Offset 35ºC -521 LSB
Linearity Best fit straight line (-40°C to +85°C) ±1°C

So, when the chip is at 35C the chip temperature register is supposed to read about -521. To convert that into C you need to make a calculation:

chip_temperature = ((value_read + 521) + (35 * 340)) / 340

Simplified:

chip_temperature = (value_read + 12421) / 340

3
  • This looks like the right conversion above, 35C, but I get some weirdness below, it becomes 229. Also of interesting note, the well known i2cdevlib library has code for the MPU6050, and example code exists for reading temperature using mpu.readTemperature(); however, no such method seems to exist in the library (anymore?). There is something called getTemperature(); but that gives out data raw, not converted. How very strange.
    – Charlie
    Commented Jul 16, 2021 at 2:11
  • 1
    I would check the math and also pay attention if the code is performing integer arithmetic and causing rounding errors. In which case add decimal points to your numbers in an effort to force floating point math. I'm not familiar with i2cdevlib as I've been using the drivers from the OEM. But if no one answers your question here, I would post an issue (ask your question) over in the i2cdevlib github web pages.
    – st2000
    Commented Jul 16, 2021 at 13:15
  • Yeah, I suspected it was something like that. Re-inspired, I took another crack at casting all the variables, and I got it to behave more or less as it should. Looks like it was because I wasn't casting the uint16 returned (what would be value_read above) up to float before adding and dividing. Incidentally, I'm using a Longan nano, not an Arduino. The inbuilt screen lib for displaying text doesn't like floats, so I was trying to avoid them. Looks like I was trying too hard. Either way, the math you provide is good. +1
    – Charlie
    Commented Jul 17, 2021 at 9:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.