Skip to content
This repository has been archived by the owner on Dec 8, 2019. It is now read-only.

Commit

Permalink
Merge pull request #24 from cribbstechnologies/master
Browse files Browse the repository at this point in the history
Add Heat Index to JSON payload
  • Loading branch information
bruhautomation committed Jul 7, 2017
2 parents 75fc667 + 8c9804a commit 81fabb7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
26 changes: 26 additions & 0 deletions bruh_mqtt_multisensor_github/bruh_mqtt_multisensor_github.ino
Expand Up @@ -351,6 +351,7 @@ void sendState() {
root["motion"] = (String)motionStatus;
root["ldr"] = (String)LDR;
root["temperature"] = (String)tempValue;
root["heatIndex"] = (String)calculateHeatIndex(humValue, tempValue);


char buffer[root.measureLength() + 1];
Expand All @@ -361,6 +362,31 @@ void sendState() {
}


/*
* Calculate Heat Index value AKA "Real Feel"
* NOAA heat index calculations taken from
* http://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml
*/
float calculateHeatIndex(float humidity, float temp) {
float heatIndex= 0;
if (temp >= 80) {
heatIndex = -42.379 + 2.04901523*temp + 10.14333127*humidity;
heatIndex = heatIndex - .22475541*temp*humidity - .00683783*temp*temp;
heatIndex = heatIndex - .05481717*humidity*humidity + .00122874*temp*temp*humidity;
heatIndex = heatIndex + .00085282*temp*humidity*humidity - .00000199*temp*temp*humidity*humidity;
} else {
heatIndex = 0.5 * (temp + 61.0 + ((temp - 68.0)*1.2) + (humidity * 0.094));
}

if (humidity < 13 && 80 <= temp <= 112) {
float adjustment = ((13-humidity)/4) * sqrt((17-abs(temp-95.))/17);
heatIndex = heatIndex - adjustment;
}

return heatIndex;
}


/********************************** START SET COLOR *****************************************/
void setColor(int inR, int inG, int inB) {
analogWrite(redPin, inR);
Expand Down
6 changes: 6 additions & 0 deletions example_home_assistant_configuration.yaml
Expand Up @@ -42,6 +42,12 @@ sensor:
name: "SN1 Temperature"
unit_of_measurement: "°F"
value_template: '{{ value_json.temperature | round(1) }}'

- platform: mqtt
state_topic: "bruh/sensornode1"
name: "SN1 Real Feel"
unit_of_measurement: "°F"
value_template: '{{ value_json.heatIndex | round(1) }}'


group:
Expand Down

0 comments on commit 81fabb7

Please sign in to comment.