Created
December 18, 2014 08:59
-
-
Save miyamoto-daisuke/47f5ce9cd5c6d42fbc8d to your computer and use it in GitHub Desktop.
TriSens
This file contains 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
console.log("TriSens"); | |
var mraa = require('mraa'); | |
console.log('MRAA Version: ' + mraa.getVersion()); | |
var tempPin = new mraa.Aio(0); | |
var lightPin = new mraa.Aio(1); | |
var soundPin = new mraa.Aio(2); | |
var B = 3975; // B value of the thermistor | |
function toCelsius(v) { | |
var resistance = (1023 - v) * 10000 / v; | |
var celsius_temperature = 1 / (Math.log(resistance / 10000) / B + 1 / 298.15) - 273.15; | |
return celsius_temperature; | |
} | |
setInterval(function () { | |
var time = new Date(); | |
console.log("==== " + time + " ===="); | |
var tempValue = tempPin.read(); | |
var lightValue = lightPin.read(); | |
var soundValue = soundPin.read(); | |
console.log("tempPin Value: " + toCelsius(tempValue)); | |
console.log("lightPin Value: " + lightValue); | |
console.log("soundPin Value: " + soundValue); | |
}, 5000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment