Skip to content

Instantly share code, notes, and snippets.

@voodootikigod
Created September 19, 2012 20:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save voodootikigod/3752122 to your computer and use it in GitHub Desktop.
Save voodootikigod/3752122 to your computer and use it in GitHub Desktop.
Johnny-Five Sensor to read a TMP36 Temperature Sensor, Circuit board: http://www.oomlout.com/a/products/ardx/circ-10
var five = require("johnny-five"),
board, sensor;
board = new five.Board();
board.on("ready", function() {
sensor = new five.Sensor({ pin: 0, freq: 250 });
board.repl.inject({
sensor: sensor
});
sensor.on("change", function(err, reading) {
var voltage = reading * .004882814;
// For Fahrenheit
var temperature = (((voltage - .5) * 100)*1.8) + 32;
// For Celsius
// var temperature = ((voltage - .5) * 100);
console.log( temperature );
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment