Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
arduino.on('ready', function () {
// Access the temperature sensor on pin A0
var thermometer = new five.Thermometer({
controller: 'LM35',
pin: 'A0',
freq: 1000
});
// Data event listener with callback function
// Will capture incoming sensor readings
thermometer.on('data', function () {
// Callback has readings in celsius, fahrenheit and kelvin
console.log(this.C + '°C');
console.log(this.F + '°F');
console.log(this.K + '°K');
console.log('========');
});
});
board.on('ready', function start() {
var pH_reading,
eC_reading,
data_interval,
water_temp,
acidpump = new five.Pin(4),
basepump = new five.Pin(5),
ph_power = new five.Pin(12),
ph_sensor = new five.Sensor('A1');
// This requires OneWire support using the ConfigurableFirmata
let thermometer = new five.Thermometer({
controller: 'DS18B20',
pin: 3
});
thermometer.on('change', function() {
// console.log(this.celsius + "°C");
water_temp = this.celsius;
});
ph_power.high();
// Hack: Relays are inversed... make sure pumps are off.
// Better hardware could take care of this... I'm not an electrical engineer.
acidpump.high();
basepump.high();
five.Board().on('ready', function() {
var temperature = new five.Thermometer({
controller: 'LM35',
pin: 'A0' // Analog pin A0
})
temperature.on('data', function() {
console.log(this.celsius)
// tip: Too many decimal points? Try Math.round()
// want to change the temperature? breathe on it!
// https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Math/round
// tip: Too jittery sensor value?
// Try a low pass filter / smoothing algorithm / moving average
// E.g. https://github.com/osuushi/Smooth.js/ or https://www.arduino.cc/en/Tutorial/Smoothing
})
})
board.on("ready", function() {
const led = new five.Led("GPIO4");
const button = new five.Button("GPIO17");
const temperature = new five.Thermometer({
controller: "MCP9808"
});
const opts = {
width: 128,
height: 64,
address: 0x3C
};
const oled = new Oled(board, five, opts);
const font = require('oled-font-5x7');
let ledStatus = "on";
let isMonitoring = true;
// Turn on LED and set up OLED
led.on();
oled.fillRect(1, 1, 128, 64, 0);
oled.setCursor(1, 1);
board.on('ready', () => {
let temperature = new five.Thermometer({
controller: 'DS18B20',
pin: 3,
freq: 1000
});
temperature.on('data', () => {
console.log(`${temperature.celsius}°C on 0x${temperature.address.toString(16)}`);
});
});
board.on("ready", function() {
var temperature = new five.Thermometer({
controller: "MPU6050"
});
var button = new five.Button(4);
board.repl.inject({
button: button
});
button.on("down", function() {
request.post({url:'https://fb.jagels.us/bot/doorbell', body:'DING DONG!'}, function(err, res, body) {
if (err) {
return console.error('Doorbell not acknowledged: ', err);
}
console.log('Message sent! Server responded with: ', body);
});
board.on('ready', function() {
const thermometer = new five.Thermometer({
controller: 'MCP9808'
});
thermometer.on('change', function() {
console.log('celsius: %d', this.C);
console.log('fahrenheit: %d', this.F);
console.log('kelvin: %d', this.K);
});
});
var five = require('johnny-five')
var raspi = require('raspi-io')
var thermometer = {
controllerName: 'MPU6050',
instance: new five.Thermometer({
controller: 'MPU6050'
}),
init(client) {
var that = this
this.instance.on('change',function() {
client.emit('changeT',this.celsius)
})
client.on('updateTemperature',function() {
client.emit('changeT',that.instance.celsius)
})
}
}
module.exports = thermometer
board.on('ready', function() {
const thermometer = new five.Thermometer({
controller: 'MCP9808'
});
thermometer.on('change', function() {
console.log('celsius: %d', this.C);
console.log('fahrenheit: %d', this.F);
console.log('kelvin: %d', this.K);
});
});
board.on('ready', function () {
var sensor = new five.Thermometer({
controller: 'TMP36',
pin: 'A0'
})
var temp = null
sensor.on('data', function () {
temp = this.celsius
})
var server = dnode(
{
getTemperature: function (cb) {
cb(temp)
}
},
{ weak: false }