JavaScript Hardware

JaxNode April 2016

Left-Pad Apocolapse

  • Conflict on the 'kik' module name
  • Developer un-published all of his modules 
  • One of the modules was 'Left-Pad'.
  • Internet Broke!
  • 11 line module
module.exports = leftpad;
function leftpad (str, len, ch) {
  str = String(str);
  var i = -1;
  if (!ch && ch !== 0) ch = ' ';
  len = len - str.length;
  while (++i < len) {
    str = ch + str;
  }
  return str;
}
  • Dave Haney's Blog post
  • http://www.haneycodes.net/npm-left-pad-have-we-forgotten-how-to-program/

IoT Two parter

  • JaxARCSIG next Thursday
  • Particle platform and Cloud
  • Particle Photon
  • Particle Electron
  • Connecting to the cloud with Node

Why JavaScript

JavaScript on Micro-controllers?

Easier to tweak the software than hardware

Arduino has horrible IDE, no debugging

Easy to make event based

Run single-threaded

Can use low power, low RAM

 

Board options

  • Espruino Board
  • Espruino Pico 
  • Tessel (Node.js)
  • ESP8266 (Install Espruino)
  • Raspberry PI
  • BeagleBone Black

Espruino Pico

22 GPIO pins : 9 Analogs inputs

ARM Cortex M4, 384kb flash, 96kb 

3.3v 250mA voltage regulator, accepts voltages from 3.5v to 16v

JavaScript Interpreter ES5 Compat

$25

WiFi

10/100 Mb Ethernet

2 plug and play module ports

2 USB ports

580 MHz Mediatek MT7620n

64MB RAM

32MB Flash memory

$45

Run Node.js!

Tessel History

  • Original board four ports
  • WiFI only
  • Colony version of Node
  • No operating system
  • Open Source hardware

Tessel 2 features

  • Runs on Linux
  • Closer to Raspberry Pi than Arduino
  • Better performance than Micro-controller
  • Runs full version of Node.js
  • Can also run Python and Rust
  • Now runs Johnny-five

Raspberry PI 3

1200 Mhz 4 core ARM CPU

4 USB ports

Ethernet

On board WiFi and BLE

40 GPIO pins

HDMI

2.5 AMP power

Run Windows and Linux

$35

ESP8266

Cheap WiFi micro-controller

Want to use newer Esp-12

Flash with Espruino

$2

Espruino

Interpreted JavaScript

96Kb RAM

Espruino IDE

Light weight modules

Requires bread board or Soldering

WiFi optional

Tessel 2

Runs full version of Node

64 MB RAM

IDE of your choice

Can use NPM

USB and PnP modules

Builtin Ethernet

Builtin WiFi

Espruino Functions

  • digitalWrite(A1,1)
  • digitalRead(A1)
  • analogRead(B0)
  • analogWrite(A0, 0.5, { freq: 10 })
  • reset()
  • save()

Tessel 2

  • Actual Computer
  • OpenWRT OS
  • Open Source Router
  • t2 command line tooling
  • deploy code over WiFi

t2

  • npm install -g t2-cli 
  • t2 list
  • t2 wifi -n <SSID> -p <passcode>
  • t2 init
  • t2 run index.js
  • t2 push index.js
  • t2 erase

Johnny-Five

  • johnny-five.io
  • Run natively on Tessel 2 or Pi
  • Bocoup owns IP related to Technical Machine
  • require('tessel-io') plugin on Tessel
  • require('rasp-io') plugin on the Pi
// 1
var five = require("johnny-five");
// 2
var Tessel = require("tessel-io");
// 3
var board = new five.Board({
  // 4
  io: new Tessel()
});
// 5
board.on("ready", function() {
  // 6
  var led = new five.Led("a0");
  // 7
  led.blink(500);
});

DEMO

Questions?

Made with Slides.com