Configuring the modules
We are now going to configure each of the modules of our home automation system, so we can access them remotely later. The goal here is to configure the modules to respond to commands coming from our central server and to not act as independent units, as shown in earlier chapters.
Let's start with the sensors module; this is the complete code for this module:
// Modules var express = require('express'); var sensorLib = require('node-dht-sensor'); // Express app var app = express(); // aREST var piREST = require('pi-arest')(app); piREST.set_id('4g0d7f'); piREST.set_name('sensor_module'); piREST.set_mode('bcm'); // Start server app.listen(3000, function () { console.log('Raspberry Pi Zero motion sensor started!'); }); // Sensor loop var sensor = { initialize: function () { return sensorLib.initialize(11, 4); }, read: function () { var readout = sensorLib.read...