Heat Index
Turns temperature (°C) and relative humidity (%) into the NWS heat index, the temperature the air actually feels like, plus its NWS risk level (Caution, Extreme caution, Danger, Extreme danger). When the formula doesn’t apply it reports “Below range” instead of guessing, and it writes nothing if a reading is missing.
Who it’s for
People who watch a warehouse, greenhouse, factory floor or care home, where the rule for when work slows or stops is written against felt temperature, not the thermometer. They already collect temperature and humidity, and they want to know “is it Caution or Danger right now?” without converting the readings by hand.
What it does
It reads the latest temperature (°C) and relativeHumidity (%) telemetry of the device and computes the heat index, the temperature the air actually feels like, as defined by the US National Weather Service (NWS).
It uses the NWS heat index formula (Rothfusz, 1990) with the NWS low and high humidity adjustments. The temperature is converted to °F for the formula, and the result is converted back to °C:
It writes two time series on the same entity: heatIndex, the heat index in °C with one decimal, and heatIndexLevel, the NWS risk level (Caution, Extreme caution, Danger, Extreme danger or Below range).
The formula only applies when the heat index is 26.7 °C (80 °F) or higher. NWS checks this with a simple estimate first. If that estimate, or the final result, is below 80 °F, the field writes only heatIndexLevel = Below range and no heatIndex number, instead of guessing one. Because no number is written in that case, the latest heatIndex still shows the last result in range, so read heatIndexLevel first and hide or grey out heatIndex when it is Below range.
If either reading has not arrived yet, or humidity is outside 0 - 100 %, nothing is written, so a dashboard never shows a confident wrong number.
The formula matches the NWS heat index chart to within about ±0.7 °C (±1.3 °F). It was fitted to air temperatures up to about 43 °C (110 °F). Above that, treat both the number and the level as rough estimates. It does not cover wet-bulb globe temperature, solar load, wind or per-person factors.
For example, 32.2 °C at 70 % gives 41.0 °C (Danger), 35.6 °C at 10 % gives 32.5 °C (Extreme caution), and 22 °C at 50 % gives only Below range.
How to customize
- To use different telemetry keys - change the Time series key on the
temperatureandrelativeHumidityarguments to match what your sensors publish. - To feed temperature in °F - change
var t = temperature * 9.0 / 5.0 + 32.0;tovar t = temperature;. - To output the heat index in °F - return
Math.round(hi * 10.0) / 10.0asheatIndexinstead ofhiC. - To rename the outputs - change the
heatIndexandheatIndexLevelkeys in the script’sreturnstatements. - To match the levels in your own safety policy - edit the thresholds in the
if (hi >= ...)chain (values are in °F) and the label strings next to them. - To colour a dashboard by level - use
heatIndexLevelin the widget’s value-to-colour mapping. No lookup is needed. - To raise an alarm on a level - create an alarm rule on
heatIndexLevelequal toDangerorExtreme danger.
Share Your Calculated Field with the Community
Built a useful data transformation? Export it as a JSON from ThingsBoard and publish it to the IoT Hub. Share it with thousands of ThingsBoard developers worldwide.