mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-23 02:36:35 +00:00
Add heatindex to BMP driver (#4771)
This commit is contained in:
parent
d30c634515
commit
9a5217bf90
@ -860,6 +860,8 @@ float CalcTempHumToDew(float t, float h) {
|
||||
|
||||
#ifdef USE_HEAT_INDEX
|
||||
float CalcTemHumToHeatIndex(float t, float h) {
|
||||
if (isnan(h) || isnan(t)) { return NAN; }
|
||||
|
||||
if (!Settings->flag.temperature_conversion) { // SetOption8 - Switch between Celsius or Fahrenheit
|
||||
t = t * 1.8f + 32; // Fahrenheit
|
||||
}
|
||||
@ -881,7 +883,10 @@ float CalcTemHumToHeatIndex(float t, float h) {
|
||||
hi += ((h - 85.0) * 0.1) * ((87.0 - t) * 0.2);
|
||||
}
|
||||
}
|
||||
return (Settings->flag.temperature_conversion) ? hi : (hi - 32) / 1.8f;
|
||||
if (!Settings->flag.temperature_conversion) { // SetOption8 - Switch between Celsius or Fahrenheit
|
||||
hi = (hi - 32) / 1.8f; // Celsius
|
||||
}
|
||||
return hi;
|
||||
}
|
||||
#endif // USE_HEAT_INDEX
|
||||
|
||||
|
@ -583,14 +583,23 @@ void BmpShow(bool json) {
|
||||
float f_dewpoint = CalcTempHumToDew(bmp_temperature, bmp_humidity);
|
||||
char dewpoint[33];
|
||||
dtostrfd(f_dewpoint, Settings->flag2.temperature_resolution, dewpoint);
|
||||
#ifdef USE_HEAT_INDEX
|
||||
float f_heatindex = CalcTemHumToHeatIndex(bmp_temperature, bmp_humidity);
|
||||
char heatindex[33];
|
||||
dtostrfd(f_heatindex, Settings->flag2.temperature_resolution, heatindex);
|
||||
#endif // USE_HEAT_INDEX
|
||||
#ifdef USE_BME68X
|
||||
char gas_resistance[33];
|
||||
dtostrfd(bmp_sensors[bmp_idx].bmp_gas_resistance, 2, gas_resistance);
|
||||
#endif // USE_BME68X
|
||||
|
||||
if (json) {
|
||||
char json_humidity[80];
|
||||
char json_humidity[100];
|
||||
#ifdef USE_HEAT_INDEX
|
||||
snprintf_P(json_humidity, sizeof(json_humidity), PSTR(",\"" D_JSON_HUMIDITY "\":%s,\"" D_JSON_DEWPOINT "\":%s,\"" D_JSON_HEATINDEX "\":%s"), humidity, dewpoint, heatindex);
|
||||
#else
|
||||
snprintf_P(json_humidity, sizeof(json_humidity), PSTR(",\"" D_JSON_HUMIDITY "\":%s,\"" D_JSON_DEWPOINT "\":%s"), humidity, dewpoint);
|
||||
#endif // USE_HEAT_INDEX
|
||||
char json_sealevel[40];
|
||||
snprintf_P(json_sealevel, sizeof(json_sealevel), PSTR(",\"" D_JSON_PRESSUREATSEALEVEL "\":%s"), sea_pressure);
|
||||
#ifdef USE_BME68X
|
||||
@ -631,6 +640,9 @@ void BmpShow(bool json) {
|
||||
if (bmp_sensors[bmp_idx].bmp_model >= 2) {
|
||||
WSContentSend_PD(HTTP_SNS_HUM, name, humidity);
|
||||
WSContentSend_PD(HTTP_SNS_DEW, name, dewpoint, TempUnit());
|
||||
#ifdef USE_HEAT_INDEX
|
||||
WSContentSend_PD(HTTP_SNS_HEATINDEX, name, heatindex, TempUnit());
|
||||
#endif // USE_HEAT_INDEX
|
||||
}
|
||||
WSContentSend_PD(HTTP_SNS_PRESSURE, name, pressure, PressureUnit().c_str());
|
||||
if (Settings->altitude != 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user