15 float const temp_fahrenheit =
16 1.8 * (inputs[0] - 273.15) +
18 float const relative_humidity =
23 float heat_index_temperature;
25 if (temp_fahrenheit <= 40) {
26 heat_index_temperature = temp_fahrenheit;
30 heat_index_temperature =
31 -10.3 + 1.1 * temp_fahrenheit + 0.047 * relative_humidity;
32 if (heat_index_temperature > 79) {
35 const float c1 = -42.379;
36 const float c2 = 2.04901523;
37 const float c3 = 10.14333127;
38 const float c4 = -0.22475541;
39 const float c5 = -0.00683783;
40 const float c6 = -0.05481717;
41 const float c7 = 0.00122874;
42 const float c8 = 0.00085282;
43 const float c9 = -0.00000199;
46 float heat_index_temperature =
47 c1 + c2 * temp_fahrenheit + c3 * relative_humidity +
48 c4 * temp_fahrenheit * relative_humidity +
49 c5 * pow(temp_fahrenheit, 2) + c6 * pow(relative_humidity, 2) +
50 c7 * pow(temp_fahrenheit, 2) * relative_humidity +
51 c8 * temp_fahrenheit * pow(relative_humidity, 2) +
52 c9 * pow(temp_fahrenheit, 2) * pow(relative_humidity, 2);
56 if (relative_humidity <= 13 && 80 <= temp_fahrenheit &&
57 temp_fahrenheit <= 112) {
58 heat_index_temperature = heat_index_temperature -
59 ((13 - relative_humidity) / 4) *
60 sqrt(17 - abs(temp_fahrenheit - 95) / 17);
65 else if (relative_humidity > 85 && 80 <= temp_fahrenheit &&
66 temp_fahrenheit <= 87) {
67 heat_index_temperature =
68 heat_index_temperature +
69 0.02 * (relative_humidity - 85) * (87 - temp_fahrenheit);
73 this->
emit((heat_index_temperature - 32) / 1.8 +
83 const float heat_index_temperature =
85 String heat_index_effect =
"";
86 if (heat_index_temperature > 54) {
87 heat_index_effect =
"Extreme danger";
88 }
else if (heat_index_temperature > 41) {
89 heat_index_effect =
"Danger";
90 }
else if (heat_index_temperature > 32) {
91 heat_index_effect =
"Extreme Caution";
92 }
else if (heat_index_temperature > 27) {
93 heat_index_effect +
"Caution";
96 this->
emit(heat_index_effect);