Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
board.on("ready", function() {
console.log("Board connected...");
var temperature = new five.Temperature({
controller: "TMP36",
pin: "A2",
freq: 500
});
// When temperature data is read based on the freq,
// send a messge to Nitrogen
temperature.on("data", function(err, data) {
var c = Math.floor(data.celsius);
// Create a Nitrogen message
var message = new nitrogen.Message({
type: 'temperature',
tags: nitrogen.CommandManager.commandTag('demo_temp'),
body: {
{
console.log("Device Ready to connect its dots");
var lght = 0;
var temp = 25;
var light = new five.Sensor({
pin: "A2"
});
light.on("change", function() {
console.log("light: %d", this.value);
lght = this.value;
});
var temperature = new five.Temperature({
controller: "GROVE",
pin: "A0"
});
temperature.on("change", function() {
console.log("celsius: %d", this.celsius);
console.log("fahrenheit: %d", this.fahrenheit);
console.log("kelvin: %d", this.kelvin);
temp = this.celsius;
});
// send data to Azure every 500 milliseconds
setInterval(function(){
connectthedots.send_message("Light", "L", lght);
connectthedots.send_message("Temp", "C", temp);
}, 500);
board.on("ready", function() {
console.log("Board connected...");
var temperature = new five.Temperature({
controller: "TMP36",
pin: "A2",
freq: 500
});
led = new five.Led(13);
var brightness = 0;
temperature.on("data", function(err, data) {
var c, f;
c = Math.floor(data.celsius);
f = Math.floor(data.fahrenheit);
console.log(c + "°C", f + "°F");
board.on("ready", function() {
var temp = new five.Temperature({
pin: "A0",
controller: "GROVE"
});
var led = new five.Led(8);
var turnFanOn = function () {
led.on();
};
var turnFanOff = function() {
led.off();
};
var setAirResistance = function(position) {
console.log("Setting Air Resistance Position to " + position);
board.on("ready", function() {
var temp = new five.Temperature({
pin: "A0",
controller: "GROVE"
});
client.open(function (err, result) {
if (err) {
printErrorFor('open')(err);
} else {
console.log('Sending device metadata:\n' + JSON.stringify(deviceMetaData));
client.sendEvent(new Message(JSON.stringify(deviceMetaData)), printErrorFor('send metadata'));
client.on('message', function (msg) {
console.log('receive data: ' + msg.getData());
try {
var command = JSON.parse(msg.getData());
board.on("ready", function() {
var temp = new five.Temperature({
pin: "A0",
controller: "GROVE"
});
this.loop(2000, function() {
console.log("%d°C", Math.round(temp.celsius));
});
});
board.on("ready", function() {
var temp = new five.Temperature({
pin: "A0",
controller: "TMP36"
});
temp.on("change", function() {
console.log("Temp: %d", this.celsius);
});
});