重新设置温湿度大气压传感器数据处理逻辑

This commit is contained in:
95384 2025-03-07 17:17:19 +08:00
parent 5bf6c8f995
commit dfc64ef786
1 changed files with 27 additions and 60 deletions

View File

@ -1068,67 +1068,9 @@ void my_update_mcs_param(float new_wind_speed, float new_wind_dirction)
//采集温度,湿度,大气压 //采集温度,湿度,大气压
static void getTempHumiPress(void) static void getTempHumiPress(void)
{ {
//采集备用温度与大气压
float backupTemperature1; float backupTemperature1;
float backupTemperature2; //采集MS5607并判错
// uint8_t hp203_ret = get_HP203_data(&backupTemperature1, &g_stMcs_Para.pressure); if(MS56XX_GetPressure(&g_stMcs_Para.pressure) != HAL_OK)
uint8_t hp203_ret = MS56XX_GetPressureTemp(&backupTemperature1, &g_stMcs_Para.pressure);
uint8_t sht30_ret = get_temp_humi_data(&backupTemperature2, &g_stMcs_Para.humidity);
#if TEMP_SENSOR == SHT30_SENSOR
g_stMcs_Para.temperature = backupTemperature2;
#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出问题
if(tmp117_ret != HAL_OK)
{
//置错误标志位
g_error_log.temp_error_TMP117 = 1;
//使用备用温度
g_stMcs_Para.temperature = backupTemperature2;
}
else
{
//恢复错误标志位
g_error_log.temp_error_TMP117 = 0;
}
#endif /*TEMP_SENSOR == TMP117_SENSOR*/
// SHT30出问题
if(sht30_ret == FALSE)
{
//错误处理
//关电重启,第一次进入错误判断此时此时错误标志位为0关电并置位错误标志位
//再进入错误标志位检测到错误标志位后开电
//下一次监测如果SHT30恢复则正常运行如果没有恢复电继续开着保证温度传感器正常运行
// if(g_error_log.temp_error_SHT30 == 0)
// {
// HAL_GPIO_WritePin(GPIOB, GPIO_SHT_PWR_EN_Pin, GPIO_PIN_RESET);
// HAL_I2C_DeInit(&hi2c1);
// }else
// {
// HAL_GPIO_WritePin(GPIOB, GPIO_SHT_PWR_EN_Pin, GPIO_PIN_SET);
// MX_I2C1_Init();
// sht30_init();
// }
//置错误标志位
g_error_log.temp_error_SHT30 = 1;
#if TEMP_SENSOR == SHT30_SENSOR
g_stMcs_Para.temperature = 0;
#endif /*TEMP_SENSOR == SHT30_SENSOR*/
}
else
{
//恢复错误标志位
g_error_log.temp_error_SHT30 = 0;
}
//HP203B出问题
if(hp203_ret == FALSE)
{ {
//置错误标志位 //置错误标志位
g_error_log.temp_error_HP203B = 1; g_error_log.temp_error_HP203B = 1;
@ -1139,6 +1081,31 @@ static void getTempHumiPress(void)
//恢复错误标志位 //恢复错误标志位
g_error_log.temp_error_HP203B = 0; g_error_log.temp_error_HP203B = 0;
} }
//采集SHT45并判错
if(get_temp_humi_data(&backupTemperature1, &g_stMcs_Para.humidity) != HAL_OK)
{
//错误处理
//置错误标志位
g_error_log.temp_error_SHT30 = 1;
}
else
{
//恢复错误标志位
g_error_log.temp_error_SHT30 = 0;
}
//采集TMP117并判错
if(TMP117_Get_Temp(&g_stMcs_Para.temperature) != HAL_OK)
{
//置错误标志位
g_error_log.temp_error_TMP117 = 1;
//使用备用温度
g_stMcs_Para.temperature = backupTemperature1;
}
else
{
//恢复错误标志位
g_error_log.temp_error_TMP117 = 0;
}
} }
void tem_hum_update_task(void const * argument) void tem_hum_update_task(void const * argument)