Intro to Tessel

Node-compatible hardware platform


tessel.io

About Me



Clevertech

"Node-compatible"

Tessel cross-compiles your JavaScript code into a Lua virtual-machine environment which handles low-level communciation for you.

Abstraction layers!

Hardware

Modules

Examples

clone and install

$ git clone https://github.com/weisjohn/tessel-code
$ cd tessel-code/
$ npm install

A is for Ambient

var tessel = require('tessel');
var ambientlib = require('ambient-attx4');
 
var ambient = ambientlib.use(tessel.port['A']);
 
ambient.on('ready', function () {
    // get light data
    setInterval(function () {
        ambient.getLightLevel(function(err, ldata) {
            console.log(ldata.toFixed(8));
        });
    }, 500);
});

Infrared - Apple Remote

tessel-apple-remote
var tessel = require('tessel');
var port = tessel.port['B'];
var apple = require('tessel-apple-remote')(port);
var buttons = ["menu", "center", "up", "down", "right", "left", "play"]

buttons.forEach(function(b) {
    apple.on(b, function() {
        console.log(b, "pressed", "\n");
    });
    apple.on(b + ".long", function() {
        console.log(b + ".long", "pressed", "\n");
    });
});

Infrared - Repeater

infrared.on('data', function(data, other) {
    if (!reentrant) return;
    console.log('read', data.toString('hex'));
    reentrant = false;
    setTimeout(function() {
        infrared.sendRawSignal(38, data, function(err) {
            console.log(err ? "failure" : "sent");
            setTimeout(function() { reentrant = true; }, 1e3);
        });
    }, 3e3);
});

Humidity Guitar Alarm

var limit = 55;
var msg = "Warning, humidity is too high: ";

climate.readHumidity(function (err, humid) {
    if (!sent && humid > limit) {
        twilio.sendMessage({
            from: opts[2],
            to: opts[3],
            body: msg + humid.toFixed(3) + "%"
        }, function(err, resp) {
            sent = true;
        });
    }
});

Fan Control

  • state detection is hard, ymmv
  • no warranty, i am not liable
var temps = new Array();
var thermostat = 74;
var padding = 0.5;

function average(temps) {
    var sum = 0;
    var len = temps.length - 1;
    for (var i = 0; i < len; i++) {
        sum += temps[i];
    }
    return sum / len;
}

Advantages

  • On-board WiFi
  • Easy, approachable
  • No soldering (Espruino)
  • JavaScript (Firmata)
  • 90% of npm (C binding)
  • Programmatic access (CI process)

Acquisition

shop.tessel.io

Pre-order Tessel 2

Not all modules are version 2 compatible*

Coupon code: "TESSEL-MEETUP-JW"