├── README.md └── app.js /README.md: -------------------------------------------------------------------------------- 1 | Control a relay from anywhere using the Raspberry Pi 2 | ============= 3 | 4 | This is the code for the "Control a relay from anywhere using the Raspberry Pi" article on the Open Home Automation website. The article is about controlling a relay with Node.JS on the Raspberry Pi. 5 | 6 | You can find the article on the Open Home Automation website: 7 | 8 | http://www.openhomeautomation.net/control-a-relay-from-anywhere-using-the-raspberry-pi/ 9 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | // Modules 2 | var express = require('express'); 3 | var app = express(); 4 | var piREST = require('pi-arest')(app); 5 | 6 | // Set unique ID 7 | piREST.set_id('p5dgwt'); 8 | piREST.set_name('pi_cloud'); 9 | 10 | // Connect to cloud.aREST.io 11 | piREST.connect(); 12 | 13 | // Start server 14 | var server = app.listen(3000, function() { 15 | console.log('Listening on port %d', server.address().port); 16 | }); 17 | --------------------------------------------------------------------------------