Skip to content

Instantly share code, notes, and snippets.

@kevinold
Created June 3, 2014 02:51
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 kevinold/e954c5da545aa906baf0 to your computer and use it in GitHub Desktop.
Save kevinold/e954c5da545aa906baf0 to your computer and use it in GitHub Desktop.
var Spark = require("../lib/spark");
var five = require("johnny-five");
var board = new Spark({
token: process.env.SPARK_TOKEN,
deviceId: process.env.SPARK_DEVICE_ID
});
board.on("ready", function() {
console.log("CONNECTED");
board.analogRead("A7", function(data) {
//console.log( "A7", data );
var voltage = (data * 3.33)/4095;
var celsius = (voltage - 0.5) * 100;
var f = celsius * (9/5) + 32; // true c to f forumula
f = f + 29; // hack to get sensor working (add 29 so it is correct)
console.log( "The temperature is: ", f);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment