Getting temperature from LSM9DS1 - "how too"?

Hi there,
taking temp from HTS of sense and it is way off of 5-6´C just as other have described, so was thinking......hot to get temp out of the gyro?

Something, like this....but sadly do not work?

if( imu.tempAvailable() ){ // Update when new sensor data is available
imu.readTemp(); // Read the temperature
}

Klaus

The LSM9DS1 library does not have a function to read the temperature.

The library is fairly straightforward and clearly written. You could extend the library to read the temperature registers yourself.

I am happy to help if you have questions or test your modifications.

That is way over my head as code-snipper :slight_smile:

btw if only using 3,3v the temp seems sometime not to overshoot, a bit strange, like 2 out of 10 times I get the right temperature whitout the overshoot of of 5-6´C.

I would recommend using the on-board temperature sensor only for gaining programming experience. If you want to measure temperature it is best to isolate the sensor mechanically from other sources of heat e.g. your power converter or microcontroller. There are use cases where this is less of an issue. But when you want to measure room temperature it is best to keep a little distance.

On the Nano board the copper layers are good heat spreaders.

kbaggen:
btw if only using 3,3v the temp seems sometime not to overshoot, a bit strange, like 2 out of 10 times I get the right temperature whitout the overshoot of of 5-6´C.

When you use 3.3V directly the on-board voltage regulator is not used. This is likely the biggest heat source on board.

Wait, why does the LSM9DS1 even provide temperature readings? I didn't realize this was a thing till I checked the datasheet.

In any case, the registers you want are 0x16 (OUT_TEMP_H) and 0x15 (OUT_TEMP_L).

You need to read these two registers and concatenate them [H L] to form a 16 bit two's complement number. You can extend the library to do this (the accelerations are obtained using the same scheme).

I am fine at programming dsb18b20 sensors etc, so that kind of programming not an issue.....but registers is a new thing.

On MPU6050 you could get a decent temrpaturereading from the MPU, and the question as the temperature of the sense seems 5-6`C over ambient, and hence, just woundering if this would give beeter result.

Anyway I can handle it in offset code so to speak.