2023-12-21 03:25 AM - edited 2023-12-21 03:29 AM
Hello All,
Need to read the values from the embedded Temperature Sensor in LIS3DH via I2C communication
I had made the following configurations as mentioned in the datasheet,
1. CTRL_REG4(0x23) = 0X80
2. TEMP_CFG_REF (1Fh) = 0XC0
3. Trying read the temperature value from the following register OUT_ADC_3_L(0x0C) and OUT_ADC_3_H(0x0D).
- Getting the value from the OUT_ADC_3_H(0x0D) as 8. If I expose heat near to the chip the value is increasing.
How to convert this(8) value to temperature?
Kindly assist me to get the conversation formula. Here the Vdd supply = 3.3V.
Thanks in Advance.
Regards,
Surya S
2023-12-21 04:13 AM
2023-12-26 01:22 AM
Thank you for the update.
Here the thing is the unit we kept the unit under room temperature 25°C and the value read from the register OUT_ADC_3_H(0x0D) is 7. How can equate this 8 to 25°C? Attached image is for your reference.
Thanks In Advance.
2023-12-26 02:18 AM
You should be able to read both the low and high byte in a singular 2 byte read operation. What's that number pair?
Post code section using the ... </> tool in the post edit window, not as a bitmap
2023-12-26 02:33 AM
Hi,
Please find the code
ADSwrite[0] = 0x1f;
ADSwrite[1] = 0xC0;
if (HAL_I2C_Master_Transmit(&hi2c2, address << 1, ADSwrite,2, 1000) == HAL_OK)
{
if (HAL_I2C_Master_Receive(&hi2c2, address << 1, ADSread, 2, 1000) != HAL_OK)
{}
}
reg = 0X0C;
if (HAL_I2C_Master_Transmit(&hi2c2, address << 1, ®, 1, I2C_HAL_API_TIMEOUT) != HAL_ERROR)
{
if (HAL_I2C_Master_Receive(&hi2c2, address << 1, &lowByte, 1, 1000) != HAL_OK)
{}
}
reg |= 0x01;
if (HAL_I2C_Master_Transmit(&hi2c2, address << 1, ®, 1, I2C_HAL_API_TIMEOUT) != HAL_ERROR)
{
if (HAL_I2C_Master_Receive(&hi2c2, address << 1, &highByte, 1, 1000) != HAL_OK)
{ }
}
adcData = (highByte << 8) | lowByte;