Last active
August 29, 2015 14:02
-
-
Save Resseguie/3942facab36fd3cc6ab1 to your computer and use it in GitHub Desktop.
voodoospark #23 using spark-io
This file contains hidden or 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 five = require("johnny-five"), | |
Spark = require("spark-io"), | |
board, sensor; | |
// Create Johnny-Five board connected via Spark | |
board = new five.Board({ | |
io: new Spark({ | |
token: process.env.SPARK_TOKEN, | |
deviceId: process.env.SPARK_DEVICE_ID | |
}) | |
}); | |
board.on("ready", function() { | |
sensor = new five.Sensor({ | |
pin: "A7", | |
freq: 1000 | |
}); | |
sensor.on("data", function() { | |
// TMP36 | |
var mV = this.value * (3300/1024); | |
var celsius = (mV - 500) / 10; | |
var fahrenheit = celsius * (9 / 5) + 32; | |
console.log(celsius + "°C", fahrenheit + "°F"); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment