Micro Computer | Price (around) |
---|---|
Raspberry Pi 4 | ~ 190zł |
Raspberry Pi Zero | ~ 80zł |
Arduino | ~ 90zł |
ESP8266 | ~ 20zł |
const { Gpio } = require('onoff'); const LIGHT_PIN = 21; const light = new Gpio(LIGHT_PIN, 'out'); // Turn on light light.writeSync(1); // Turn off light light.writeSync(0); const BUTTON_PIN = 2; const button = new Gpio( BUTTON_PIN, 'in', 'rising', {debounceTimeout: 10} ); button.watch(async (err, value) => { if (err) { throw err; } console.log('Button pressed!'); });
const { Gpio } = require('onoff'); const LIGHT_PIN = 21; const light = new Gpio(LIGHT_PIN, 'out'); // Turn on light light.writeSync(1); // Turn off light light.writeSync(0); const BUTTON_PIN = 2; const button = new Gpio( BUTTON_PIN, 'in', 'rising', {debounceTimeout: 10} ); button.watch(async (err, value) => { if (err) { throw err; } console.log('Button pressed!'); });
const { Gpio } = require('onoff'); const LIGHT_PIN = 21; const light = new Gpio(LIGHT_PIN, 'out'); // Turn on light light.writeSync(1); // Turn off light light.writeSync(0); const BUTTON_PIN = 2; const button = new Gpio( BUTTON_PIN, 'in', 'rising', {debounceTimeout: 10} ); button.watch(async (err, value) => { if (err) { throw err; } console.log('Button pressed!'); });
const { Gpio } = require('onoff'); const LIGHT_PIN = 21; const light = new Gpio(LIGHT_PIN, 'out'); // Turn on light light.writeSync(1); // Turn off light light.writeSync(0); const BUTTON_PIN = 2; const button = new Gpio( BUTTON_PIN, 'in', 'rising', {debounceTimeout: 10} ); button.watch(async (err, value) => { if (err) { throw err; } console.log('Button pressed!'); });
crontab -e
@reboot node /home/pi/app.js &
const awsIot = require('aws-iot-device-sdk'); const device = awsIot.device({ keyPath: 'PrivateKeyPath', certPath: 'CertificatePath', caPath: 'RootCACertificatePath', clientId: 'UniqueClientIdentifier', host: 'IoTCoreEndpoint' }); device.on('connect', () => { console.log('connected'); device.publish('connected', JSON.stringify({ message: 'connected' })); device.subscribe('turnOn'); }); device.on('message', (topic) => { if (topic === 'turnOn') { console.log('Turned on'); } });
const awsIot = require('aws-iot-device-sdk'); const device = awsIot.device({ keyPath: 'PrivateKeyPath', certPath: 'CertificatePath', caPath: 'RootCACertificatePath', clientId: 'UniqueClientIdentifier', host: 'IoTCoreEndpoint' }); device.on('connect', () => { console.log('connected'); device.publish('connected', JSON.stringify({ message: 'connected' })); device.subscribe('turnOn'); }); device.on('message', (topic) => { if (topic === 'turnOn') { console.log('Turned on'); } });
const awsIot = require('aws-iot-device-sdk'); const device = awsIot.device({ keyPath: 'PrivateKeyPath', certPath: 'CertificatePath', caPath: 'RootCACertificatePath', clientId: 'UniqueClientIdentifier', host: 'IoTCoreEndpoint' }); device.on('connect', () => { console.log('connected'); device.publish('connected', JSON.stringify({ message: 'connected' })); device.subscribe('turnOn'); }); device.on('message', (topic) => { if (topic === 'turnOn') { console.log('Turned on'); } });
sudo npm install -g --unsafe-perm homebridge homebridge-config-ui-x
sudo hb-service install --user homebridge
There are over 2,000 Homebridge plugins supporting thousands of different smart
accessories.
Also you can create your own plugin!