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...');
// Plug the Temperature sensor module
// into the Grove Shield's I2C jack
th02 = new five.Multi({
controller: "TH02"
});
// Plug the LCD module into any of the
// Grove Shield's I2C jacks.
lcd = new five.LCD({
controller: 'JHD1313M1'
});
// Plug the LED module into the
// Grove Shield's D6 jack.
led = new five.Led(13);
// Plug the Button module into the
// Grove Shield's D4 jack.
button = new five.Button(4);
function connect_the_dots()
{
console.log("Device Ready to connect its dots");
var temp = 25;
var acc = 0;
var nbaccmeasures = 0;
// Initialize temperature sensor
var multi = new five.Multi({
controller: "BMP180"
});
multi.on("change", function() {
// console.log("BMP180");
// console.log(" pressure : ", this.barometer.pressure);
// console.log(" temperature : ", this.temperature.celsius)
// console.log("--------------------------------------");
temp = this.temperature.celsius;
// var currentTime = new Date().toISOString();
// send_message(format_sensor_data(settings.guid1, settings.displayname, settings.organization, settings.location, "Temperature", "C", currentTime , this.temperature.celsius), currentTime);
});
// Initialize accelerometer
var accelerometer = new five.Accelerometer({
token: 'xsG6G5PyQMKPycWN5AjZvuSD2K4GmMcn',
component: 'grow-hub',
// Properties can be updated by the API
properties: {
state: null,
duration: 2000,
interval: 5000,
targets: {},
},
light: new five.Light({
controller: 'TSL2561'
}),
multi: new five.Multi({
controller: 'SI7020'
}),
start: function () {
console.log('Grow-Hub initialized.');
// This must be called prior to any I2C reads or writes.
// See Johnny-Five docs: http://johnny-five.io
board.i2cConfig();
board.i2cRead(0x64, 32, function (bytes) {
var bytelist = [];
if (bytes[0] === 1) {
for (i = 0; i < bytes.length; i++) {
if (bytes[i] !== 1 && bytes[i] !== 0) {
bytelist.push(ascii.symbolForDecimal(bytes[i]));
board.on('ready', () => {
const monitor = new five.Multi({
controller: 'BME280',
});
// More code here!
});
board.on('ready', function start() {
// Declare needed variables.
var emit_data;
var multi = new five.Multi({
controller: 'BME280'
});
var growHub = new Grow({
uuid: '732db76b-7d92-4c6c-995f-ec0d34acf6f2',
token: '5qL8nsFpqDf7m4cY9u6uFoXDKMfGJHf2',
component: 'ClimateSensor',
properties: {
interval: 6000,
growfile: {
targets: {
temperature: {
min: 10,
max: 25
board.on('ready', function start() {
// Declare needed variables.
var pH_reading, eC_reading, water_temp, emit_data;
var floatSwitch = new five.Pin('P1-7');
var multi = new five.Multi({
controller: 'BME280'
});
// var lux = new five.Light({
// controller: 'TSL2561'
// });
var plusfarm = new Grow({
uuid: 'meow',
token: 'meow',
component: 'PlusFarm',
properties: {
light_state: null,
pump_state: null,
water_level: null,
board.on('ready', () => {
const monitor = new five.Multi({
controller: 'BME280',
});
const handleChange = throttle(() => {
const temperature = monitor.thermometer.fahrenheit;
const pressure = monitor.barometer.pressure;
const relativeHumidity = monitor.hygrometer.relativeHumidity;
// Our code here!
}, 1000);
monitor.on('change', handleChange);
});
board.on('ready', () => {
const weatherSensor = new five.Multi({
controller: 'BMP180',
freq: 5000
});
socket.on('connection', client => {
weatherSensor.on('change', () => {
client.emit('weather', {
temperature: weatherSensor.thermometer.F,
pressure: (weatherSensor.barometer.pressure * 10)
});
});
});
server.listen(3000, () => {
console.log(`http://${os.networkInterfaces().wlan0[0].address}:3000`);
});
board.on("ready", function() {
const multi = new five.Multi({
controller: "MPL3115A2",
elevation: 492
});
multi.on("change", function() {
currentTemperature = this.temperature.celsius;
console.log(this.temperature.celsius, this.barometer.pressure, this.altimeter.meters);
wsBroadcast({
temperature: this.temperature.celsius,
ts: Date.now()
});
});
multi.on("error", console.error);
});
board.on('ready', () => {
const express = require('express');
const app = express();
const http = require('http').Server(app);
const io = require('socket.io')(http);
const port = process.env.PORT || 80;
app.use(express.static(path.join(__dirname, 'public')));
app.get('/', function(req, res) {
res.sendFile(path.join(__dirname, '/public/index.html'));
});
const monitor = new five.Multi({
controller: 'BME280',
});
const handleChange = throttle(() => {
const temperature = monitor.thermometer.fahrenheit;
const pressure = monitor.barometer.pressure;
const relativeHumidity = monitor.hygrometer.relativeHumidity;
io.sockets.emit('weather updated', {
temperature,
pressure,
relativeHumidity,
});
}, 500);
monitor.on('change', handleChange);