cancel
Showing results for 
Search instead for 
Did you mean: 

[lsm303agr] How to get temperature sensor value correctly?

RChen.1654
Associate II

It is always 0 to get the value of OUT_TEMP_L_A (0Ch), OUT_TEMP_H_A (0Dh).

Before reading OUT_TEMP_L_A (0Ch), OUT_TEMP_H_A (0Dh), check the values of TEMP_CFG_REG_A (1Fh), CTRL_REG4_A (23h) and STATUS_REG_AUX_A (07h) as bellow:

TEMP_CFG_REG_A (1Fh): 0xC7

CTRL_REG4_A (23h): 0x80

STATUS_REG_AUX_A (07h): 0xFF

2 REPLIES 2
dbgarasiya
Senior II

which protocol and controller you are using?

Host side is Freescale i.MX8MQ. The STMems_Android_Sensor_HAL_Input driver from ST's website is used on Android 9.

No temperature sensor is implemented in the lsm303agr part of STMems_Android_Sensor_HAL_Input driver.

I try to add some code in the lsm303agr_acc.c to verify the temperature sensor.

In the initial function(lsm303agr_acc_hw_init), the BDU bit is set to 1 in CTRL_REG4_A (23h) and the TEMP_EN[1:0] bits are set to ‘1’ in the TEMP_CFG_REG_A (1Fh) register, too.