TMP117改为单次采样

This commit is contained in:
95384 2025-02-26 10:42:18 +08:00
parent e0c5dcd299
commit 798a442abe
3 changed files with 6 additions and 4 deletions

View File

@ -1077,6 +1077,8 @@ static void getTempHumiPress(void)
#endif /*TEMP_SENSOR == SHT30_SENSOR*/
#if TEMP_SENSOR == TMP117_SENSOR
TMP117_Init();
osDelay(20);
uint8_t tmp117_ret = TMP117_Get_Temp(&g_stMcs_Para.temperature);
// TMP117出问题

View File

@ -2,11 +2,11 @@
#include "i2c.h"
// 初始化温度传感器连续转换模式64次平均
// 初始化温度传感器
HAL_StatusTypeDef TMP117_Init(void)
{
// 配置值:连续转换模式 + AVG=64 (0x00A0)
uint8_t config_data[2] = {0x00, 0xA0}; // 高字节在前
// 配置值:
uint8_t config_data[2] = {0x0C, 0x00}; // 高字节在前,单次转换1100 0000 000012.5ms
return HAL_I2C_Mem_Write(&hi2c1, TMP117_ADDR << 1, TMP117_CONFIG_REG,
I2C_MEMADD_SIZE_8BIT, config_data, 2, 100);
}

View File

@ -20,7 +20,7 @@ HAL_StatusTypeDef TMP117_Init(void);
HAL_StatusTypeDef TMP117_Read(uint8_t reg, uint8_t *buffer);
HAL_StatusTypeDef TMP117_Get_Temp(float *temp);
#endif __TMP117_H_
#endif //__TMP117_H_