Awesome Open Source
Awesome Open Source

Cylon.js API Plugin For

Cylon.js ( is a JavaScript framework for robotics, physical computing, and the Internet of Things using Node.js

API plugins are separate from the Cylon.js main module, to make everything more modular and at the same time make Cylon.js lighter.

This repository contains the Cylon API plugin for

For more information about Cylon, check out the repo at

Build Status Code Climate Test Coverage

How to Install

$ npm install cylon cylon-api-socketio

How to Use

Make sure you have Cylon.js installed, then we can add support to cylon programs as follows:

'use strict';

var Cylon = require('cylon');

  name: 'rosie',

  connections: {
    arduino: { adaptor: 'firmata', port: '/dev/ttyACM0' }

  devices: {
    led: { driver: 'led', pin: 13 }

  work: function() {
    // for this example with sockets
    // we are going to be interacting
    // with the robot using the code in
    // ./**-client.html

// ensure you install the API plugin first:
// $ npm install cylon-api-socket-io
  host: '',
  port: '3000'


How to Connect

Once you have added the api to your Cylon.js code, and your robots are up and running, you can connect to them using using the following code:

<!doctype html>
  <meta charset="utf-8">
    <title>Simple Device Example</title>
      * { margin: 0; padding: 0; box-sizing: border-box; }
      body { font: 13px Helvetica, Arial; }
      form { background: #000; padding: 3px; position: fixed; bottom: 0; width: 100%; }
      form input { border: 0; padding: 10px; width: 90%; margin-right: .5%; }
      form button { width: 9%; background: rgb(130, 224, 255); border: none; padding: 10px; }
      #messages { list-style-type: none; margin: 0; padding: 0; }
      #messages li { padding: 5px 10px; }
      #messages li:nth-child(odd) { background: #eee; }
  <script src=""></script>
  <script src=""></script>
  <script type="text/javascript">
    var device;

    window.onload = function() {
      console.log('Setting up socket connections:');

      // We use the robot nsp (namespace) to connect to one of the devices
      // in this case the led we added in our cylon robot code
      device = io('');
      setInterval(function() {
        // There are two ways to send commands to a device,
        // The first one (we preffer this one) is by emitting
        // an event using the name of the command for the event,
        // and passing the params as regular function args.
        // eg. device.emit('angle', 180[, param2, param3, ...]);

        // In the second one you emit a 'command' event and
        // pass the command specifics inside an object.
            name: 'angle',
            args: [180, 'arg2', 'arg3']
      }, 1000);

      device.on('message', function(payload) {
        console.log('On Device');
        console.log('  Event:', payload.event);
        console.log('  Data:',;
        $('#messages').append($('<li>').text('On Device:'));
        $('#messages').append($('<li>').text('  Event:' + payload.event.toString()));
        if (!! {
          $('#messages').append($('<li>').text('  Data:' +;
        $('#messages').append($('<hr />'));

      msg = 'You have been subscribed to Cylon sockets:' + device.nsp;

    <ul id="messages"></ul>


We're busy adding documentation to Please check there as we continue to work on Cylon.js.

Thank you!


For our contribution guidelines, please go to

Release History

For the release history, please go to


Copyright (c) 2014-2015 The Hybrid Group. Licensed under the Apache 2.0 license.

Alternatives To Cylon Api Socketio
Select To Compare

Alternative Project Comparisons
Related Awesome Lists
Top Programming Languages

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Javascript (1,119,969
Plugin (113,427
Connect (8,628
Socket Io (4,043
Javascript Framework (1,019