Skip to content

Instantly share code, notes, and snippets.

@Resseguie Resseguie/sparkio-temp.js
Last active Aug 29, 2015

Embed
What would you like to do?
voodoospark #23 using spark-io
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
You can’t perform that action at this time.