Electric Imp IO Plugin for Johnny-Five
JavaScript
Latest commit fbaf96b Jan 6, 2015 @dtex dtex Merge pull request #11 from rwaldron/5-and-tests
5 and tests
Permalink
Failed to load latest commit information.
eg v0.2.0 Dec 16, 2014
lib Added an error if the agent ID is undefined Dec 19, 2014
test
.gitignore Initial Nov 15, 2014
.npmignore
.travis.yml Add .travis.yml Dec 16, 2014
Gruntfile.js
LICENSE-MIT
package.json
readme.md
tyrion-install.png

readme.md

Imp-IO

Gitter

Build Status

Imp-io is a Firmata-compatibility IO class for writing node programs that interact with Electric Imp devices. Imp-io was built at Bocoup

Getting Started

To communicate with an Electric Imp using Johnny-Five w/ Imp-IO, you will need to upload the special Tyrion agent and device firmware through Electric Imp's IDE. We recommend you review Electric Imp's Getting Started before continuing.

Tyrion Setup

  1. Follow Electric Imp's Getting Started instructions to set up a wifi connection to your Electric Imp device.
  2. Once your Imp is setup, open the IDE (familiarize yourself here) and click Create New Model, give it a name and assign it to your device.
  3. Paste the contents of agent.nut into the Agent pane and device.nut into the Device pane: Imp Setup
  4. Expand the Active Model in the column on the left by click on the rightward arrow. The model will appear below, click on the model.
  5. Click Build and Run to finish preparing your Electric Imp.

Imp-IO Setup

In the Electric Imp IDE, locate and copy the agent id, located in agent url Look for the agent id located in the agent url:

Imp Setup

Store your agent ID in a dot file so it can be accessed as a property of process.env. Create a file in your home directory called .imprc that contains:

export IMP_AGENT_ID="your agent id"

Then add the following to your dot-rc file of choice:

source ~/.imprc

Blink an Led

The "Hello World" of microcontroller programming:

var Imp = require("imp-io");
var board = new Imp({
  agent: process.env.IMP_AGENT_ID
});

board.on("ready", function() {
  console.log("CONNECTED");
  this.pinMode(9, this.MODES.OUTPUT);

  var byte = 0;

  // This will "blink" the on board led
  setInterval(function() {
    this.digitalWrite(9, (byte ^= 1));
  }.bind(this), 1000);
});

Johnny-Five IO Plugin

Imp-IO can be used as an IO Plugin for Johnny-Five:

var five = require("johnny-five");
var Imp = require("imp-io");

var board = new five.Board({
  io: new Imp({
    agent: process.env.IMP_AGENT_ID
  })
});

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

License

See LICENSE file.