Skip to content

Commit

Permalink
fixed heat index returned value
Browse files Browse the repository at this point in the history
the function was returning a °F value even if the class was instanced
with a °C scale
  • Loading branch information
marcellobarile committed Nov 20, 2015
1 parent 7197c99 commit a2af192
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Software/NodeJS/libs/package.json
@@ -1,6 +1,6 @@
{
"name": "node-grovepi",
"version": "2.0.6",
"version": "2.0.7",
"description": "GrovePi library for Node.js",
"keywords": ["grovepi", "robot", "gpio", "i2c"],
"dependencies": {
Expand Down
10 changes: 6 additions & 4 deletions Software/NodeJS/libs/sensors/DHTDigitalSensor.js
Expand Up @@ -14,11 +14,11 @@ function convertFtoC(temp) {
}
function getHeatIndex(temp, hum, scale) {
// http://www.wpc.ncep.noaa.gov/html/heatindex_equation.shtml
if (typeof scale == 'undefined' || scale == DHTDigitalSensor.CELSIUS) {
temp = convertCtoF(temp)
}
var needsConversion = typeof scale == 'undefined' || scale == DHTDigitalSensor.CELSIUS

temp = needsConversion ? convertCtoF(temp) : temp

return -42.379 +
var hi = -42.379 +
2.04901523 * temp +
10.14333127 * hum +
-0.22475541 * temp * hum +
Expand All @@ -27,6 +27,8 @@ function getHeatIndex(temp, hum, scale) {
0.00122874 * Math.pow(temp, 2) * hum +
0.00085282 * temp * Math.pow(hum, 2) +
-0.00000199 * Math.pow(temp, 2) * Math.pow(hum, 2)

return needsConversion ? convertFtoC(hi) : hi
}

DHTDigitalSensor.prototype = new DigitalSensor()
Expand Down

0 comments on commit a2af192

Please sign in to comment.