Home

Awesome

Galileo/Edison/Joule-IO

Travis Build Status

Compatible with Intel's Galileo Generation 2 (no longer supports Galileo Generation 1), Edison (Mini and Arduino Board, SparkFun GPIO & Arduino Blocks, Xadow Board, DFRobot Romeo & IO Expansion) and Joule boards.

Galileo/Edison/Joule-IO is a Firmata.js-compatibility class for writing Node.js programs that run on the Intel Galileo, Intel Edison, or Intel Joule. This project was built at Bocoup

Getting Started

Galileo/Edison/Joule-IO scripts are run directly on the Galileo, Edison or Joule board. To get started, complete the appropriate setup instructions:

Installation

npm install galileo-io johnny-five

If you want, you can also use the alias modules:

For Edison:

npm install edison-io johnny-five

For Joule:

npm install joule-io johnny-five

But keep in mind that these modules only delegate directly back to this module.

Usage

This module is intended for use as an IO-Plugin for Johnny-Five.

Pin Identity and Access by Platform

Intel Joule (Carrier Board)

The Intel Joule + Carrier Breakout has two "Breakout connectors":

The usable pins and additional capabilities are shown here:

Pins may be addressed by either "Breakout Name" or "Pin Number":

Breakout NamePin NumberCapability
B1_11GPIO
B1_22GPIO
B1_44GPIO
B1_55GPIO
B1_66GPIO
B1_77GPIO, UART 0 TX
B1_88GPIO
B1_1010GPIO
B1_1111GPIO, I2C 0 SDA
B1_1212GPIO
B1_1313GPIO, I2C 0 SCL
B1_1414GPIO
B1_1515GPIO, I2C 1 SDA
B1_1616GPIO
B1_1717GPIO, I2C 1 SCL
B1_1818GPIO
B1_1919GPIO, I2C 2 SDA
B1_2020GPIO
B1_2121GPIO, I2C 2 SCL
B1_2222GPIO, UART 1 TX
B1_2424GPIO, UART 1 RX
B1_2626GPIO, PWM 0
B1_2828GPIO, PWM 1
B1_3030GPIO, PWM 2
B1_3232GPIO, PWM 3
B1_3535GPIO
B2_1151GPIO
B2_1353GPIO
B2_1555GPIO
B2_1757GPIO
B2_1959GPIO
B2_2161GPIO
B2_2262GPIO
B2_2363GPIO
B2_2464GPIO
B2_2565GPIO
B2_2666GPIO
B2_2767GPIO
B2_2868GPIO, UART 0 RX
B2_2969GPIO
B2_3070GPIO
B2_3171GPIO, I2C 1 SDA
B2_3272GPIO
B2_3373GPIO, I2C 1 SCL
B2_3474GPIO, UART 1 TX
B2_3575GPIO, I2C 2 SDA
B2_3676GPIO, UART 1 RX
B2_3777GPIO, I2C 1 SCL
B2_3979GPIO
B2_4080GPIO
L0, GP100100LED100
L1, GP101101LED101
L2, GP102102LED102
L3, GP103103LED103

NOTES

Basic Example:

npm install joule-io johnny-five
var five = require("johnny-five");
var Joule = require("joule-io");
var board = new five.Board({
  io: new Joule()
});

board.on("ready", function() {
  var led = new five.Led(103);
  led.blink(500);
});
var five = require("johnny-five");
var Joule = require("joule-io");
var board = new five.Board({
  io: new Joule()
});

board.on("ready", function() {
  var rgb = new five.Led.RGB({
    // Specifying an alternate bus: 
    bus: 1,
    controller: "BLINKM",
  });

  rgb.color("red");
});

Intel Edison Arduino

The Intel Edison + Arduino Breakout has a pin-out form similar to an Arduino Uno. Use the pin numbers as printed on the board, eg. 3, 13, or "A0".

Example:

npm install edison-io johnny-five
var five = require("johnny-five");
var Edison = require("edison-io");
var board = new five.Board({
  io: new Edison()
});

board.on("ready", function() {
  var led = new five.Led(13);
  led.blink(500);
});

Intel Edison Mini Breakout

The Intel Edison + Mini Breakout has a dense pin-out form comprised of four rows, J17, J18, and J19, J20. Each pin is numbered, left-to-right, from 14 to 1 (if looking from the back). Use the row and column name ("J17-1"), or the corresponding GPIO ("GP182"), or pin number 0, to interact with that pin. (Note: "J17-1", "GP182" and 0 refer to the same pin). See the table of valid pins below to determine corresponding Pin names and numbers. *

Connection to bus 1:

I2C-1-SDAI2C-1-SCL
J17-8J18-6

Example:

npm install edison-io johnny-five
var five = require("johnny-five");
var Edison = require("edison-io");
var board = new five.Board({
  io: new Edison()
});

board.on("ready", function() {
  var led = new five.Led("J17-1");
  /*
    Same as: 

    var led = new five.Led(0);
    var led = new five.Led("GP182");
   */
  led.blink(500);
});

SparkFun Edison GPIO Block

The SparkFun Edison GPIO Block has two columns of pins. Use the GPIO name printed on the board ("GP44"), or the corresponding row and column name ("J19-4"), or pin number (31), to interact with that pin. (Note: "J19-4", "GP44" and 31 refer to the same pin). See the table of valid pins below to determine corresponding Pin names and numbers. *

Example:

npm install edison-io johnny-five
var five = require("johnny-five");
var Edison = require("edison-io");
var board = new five.Board({
  io: new Edison()
});

board.on("ready", function() {
  var led = new five.Led("GP44");
  /*
    Same as: 

    var led = new five.Led(31);
    var led = new five.Led("J19-4");
   */
  led.blink(500);
});

SparkFun Edison Arduino Block

The SparkFun Edison Arduino Block connects to the Edison via Serial1, or /dev/ttyMFD1. This means that a user must upload StandardFirmata via FTDI programmer. Johnny-Five does not use Galileo/Edison/Joule-IO to communicate with the hardware on this block, instead it communicates via the serial connection, using its default Firmata.js (this is installed by Johnny-Five automattically. The port name must be specified:

// This code runs on the Edison, communicating with the 
// SparkFun Arduino Block via Serial1 (/dev/ttyMFD1)
var five = require("johnny-five");
var board = new five.Board({
  port: "/dev/ttyMFD1"
});

board.on("ready", function() {
  var led = new five.Led(13);
  led.blink(500);
});

SparkFun Edison I2C Block

Galileo/Edison/Joule-IO/Edison-IO will automatically connect to bus 1, which is the bus used by this block.

SparkFun Edison 9DOF Block

Galileo/Edison/Joule-IO/Edison-IO will automatically connect to bus 1, which is the bus used by this block.

Edison Mini Pin Mapping Table *

Pin NumberPhysical PinEdison Pin
0J17-1GP182
4J17-5GP135
6J17-7GP27
7J17-8GP20
8J17-9GP28
9J17-10GP111
10J17-11GP109
11J17-12GP115
13J17-14GP128
14J18-1GP13
15J18-2GP165
19J18-6GP19
20J18-7GP12
21J18-8GP183
23J18-10GP110
24J18-11GP114
25J18-12GP129
26J18-13GP130
31J19-4GP44
32J19-5GP46
33J19-6GP48
35J19-8GP131
36J19-9GP14
37J19-10GP40
38J19-11GP43
39J19-12GP77
40J19-13GP82
41J19-14GP83
45J20-4GP45
46J20-5GP47
47J20-6GP49
48J20-7GP15
49J20-8GP84
50J20-9GP42
51J20-10GP41
52J20-11GP78
53J20-12GP79
54J20-13GP80
55J20-14GP81

Intel Galileo Gen 2

Or Gen 1 if you're a glutton for punishment.

The Intel Galileo Gen 2 has a pin-out form similar to an Arduino Uno. Use the pin numbers as printed on the board, eg. 3, 13, or "A0".

Example:

var five = require("johnny-five");
var Galileo = require("galileo-io");
var board = new five.Board({
  io: new Galileo()
});

board.on("ready", function() {
  var led = new five.Led(13);
  led.blink(500);
});

Blink an Led

The "Hello World" of microcontroller programming:

(attach an LED on pin 9)

var Galileo = require("galileo-io");
var board = new Galileo();

board.on("ready", function() {
  var byte = 0;
  this.pinMode(9, this.MODES.OUTPUT);

  setInterval(function() {
    board.digitalWrite(9, (byte ^= 1));
  }, 500);
});

Johnny-Five IO Plugin

Galileo/Edison/Joule-IO is the default IO layer for Johnny-Five programs that are run on a Galileo or Edison board.

Note: On the Edison, you should require johnny-five first, followed by galileo-io. Otherwise you'll get a segmentation fault.

npm install edison-io johnny-five

Example:

var five = require("johnny-five");
var Edison = require("edison-io");
var board = new five.Board({
  io: new Edison()
});

Specify An I2C Bus

Galileo/Edison/Joule-IO will do it's best to detect the correct I2C bus to use for a given expansion board, however the process is not infallible. To specify an I2C bus:

// If the i2c bus is 1 (`/dev/i2c-1`)
var board = new Galileo({
  i2c: {
    bus: 1
  }
});

Or...

var board = new Edison({
  i2c: {
    bus: 1
  }
});

Xadow Board

Expansion boards can also be initialized with a built-in configuration object, that contains the correct I2C bus for that board:

npm install edison-io johnny-five

Example:

var five = require("johnny-five");
var Edison = require("edison-io");
var board = new five.Board({
  io: new Edison(Edison.Boards.Xadow)
});

Or

var five = require("johnny-five");
var Galileo = require("galileo-io");
var board = new five.Board({
  io: new Galileo(Galileo.Boards.Xadow)
});

Additional expansion board configurations will be added as support is implemented

API

digitalWrite(pin, 1|0)

Sets the pin to 1 or 0, which either connects it to 5V (the maximum voltage of the system) or to GND (ground).

Example:

// This will turn on the pin
board.digitalWrite(9, 1);

analogWrite(pin, value)

Sets the pin to a value between 0 and 255, where 0 is the same as LOW and 255 is the same as HIGH. This is sort of like sending a voltage between 0 and 5V, but since this is a digital system, it uses a mechanism called Pulse Width Modulation, or PWM. You could use analogWrite to dim an LED, as an example.

Example:

// Crank an LED to full brightness
board.analogWrite(9, 255);

servoWrite(pin, value)

Set the pin to a value between 0-180° to move the servo's horn to the corresponding position.

Example:

board.servoWrite(9, 180);

digitalRead(pin, handler) Setup a continuous read handler for specific digital pin.

This will read the digital value of a pin, which can be read as either HIGH or LOW. If you were to connect the pin to 5V, it would read HIGH (1); if you connect it to GND, it would read LOW (0). Anywhere in between, it’ll probably read whichever one it’s closer to, but it gets dicey in the middle.

Example:

// Log all the readings for 9
board.digitalRead(9, function(data) {
  console.log(data);
});

analogRead(pin, handler) Setup a continuous read handler for specific analog pin.

This will read the analog value of a pin, which is a value from 0 to 4095, where 0 is LOW (GND) and 4095 is HIGH (5V). All of the analog pins (A0 to A5) can handle this. analogRead is great for reading data from sensors.

Example:

// Log all the readings for A1
board.analogRead("A1", function(data) {
  console.log(data);
});

License

See LICENSE file.