Skip to content

Instantly share code, notes, and snippets.

@jmendiara
Created February 4, 2016 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmendiara/94d4b1e9ca7972cce4c5 to your computer and use it in GitHub Desktop.
Save jmendiara/94d4b1e9ca7972cce4c5 to your computer and use it in GitHub Desktop.
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