The document discusses a project to build an automated coffee machine using a Tessel 2 microcontroller board, ambient light and relay sensors, and a Node.js client/server setup. It describes the hardware components used, including the coffee machine, microcontroller, sensors, and relays. It then covers setting up the software, creating a WebSocket server to control the relay and receive sensor data, and deploying everything using npm scripts and a Makefile. Finally, it encourages starting small with hardware projects and provides some resources for learning more.
33. Tessel2 hello world
// Import the interface to Tessel hardware
var tessel = require('tessel');
// Turn one of the LEDs on to start.
tessel.led[2].on();
// Blink!
setInterval(function () {
tessel.led[2].toggle();
tessel.led[3].toggle();
}, 100);
36. Relay
Sensor
Wrap & hide hardware API
mock behavior for desktop
using ENV variables
runs on desktop
easy to test
Network
37. Server (Tessel) Client
Ready for connection
Connect and tell
server to brew coffee
turn on machine
wait for warmup
brew coffee
tell client it’s done
Client exits
turn off machine
39. "scripts": {
"deploy": "npm run cleanup && …
"local": "npm run cleanup && …
"device": "npm run cleanup && …
"cleanup": "rm -rf build; …
"t2:erase": "t2 erase",
"t2:push": "t2 push .",
"t2:run": "t2 run .",
"copy": "cp .tesselinclude …
"build": "npm run cleanup; …
"install:prod": "npm i —only…
},
use npm scripts
compose build
pipeline
run / deploy
Automate everything
40. #!/bin/bash
NODE=`which node` # find the node executable on this system
coffee: ;
${NODE} client/index.js # run the client script
.SILENT: coffee # no unnecesary makefile output
.PHONY: coffee
Makefile