Created
February 4, 2016 15:07
-
-
Save jmendiara/94d4b1e9ca7972cce4c5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sensorLib = require('node-dht-sensor'); | |
var sensor = { | |
initialize: function () { | |
return sensorLib.initialize(22, 22); | |
}, | |
read: function () { | |
var readout = sensorLib.read(); | |
console.log('Temperature: ' + readout.temperature.toFixed(2) + 'C, ' + | |
'humidity: ' + readout.humidity.toFixed(2) + '%'); | |
setTimeout(function () { | |
sensor.read(); | |
}, 2000); | |
} | |
}; | |
if (sensor.initialize()) { | |
sensor.read(); | |
} else { | |
console.warn('Failed to initialize sensor'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment