The first thing you need to figure out is what you'd like to make: a garage door opener, a gate opener, a temperature recorder, or light controller, etc.
You may want to be able to access the device, not only over your local network but over the Internet so that it is accessible from your mobile device, for example.
There are multiple IoT services and platforms that provide this type of service. Most of what these services and platforms offer is focused on the central point of trusting the virtual cloud; Beame.io is different.
Why Beame.io?
Beame.io allows the issuance of publicly-trusted TLS credentials and access directly to the target device with end-to-end encryption provided by TLS accessible from any browser in the world. In essence, you work and develop on the device as if it were a normal web server. Beame.io can deliver HTML pages, Javascript, and other normal web server functionality. And with Beame.io, the device has its own keys, cert, and a tunnel making it accessible from anywhere. There are also options in Beame.io for TLS on a local network, but that's a bigger topic.
From a security standpoint, it accomplishes several important things, like:
- A permanent hostname for the device;
- A known public key and an authorization ledger (to be able to verify validity of the cert)
- The ability to issue additional tokens for the creation of additional certs.
SCHEMATICS
CODE
this is a basic server that provides on /off of a led
var http = require('http'); var url = require('url'); var Gpio = require('onoff').Gpio; var led = new Gpio(14, 'out'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/html'}); var command = url.parse(req.url).pathname.slice(1); switch(command) { case "on": led.writeSync(1); res.end("It's ON"); break; case "off": led.writeSync(0); res.end("It's OFF"); break; default: res.end('Hello? yes, this is pi!'); } }).listen(1337); console.log("Our on off server is listening on port 1334");