How To Connect with MQTT

To use MQTT, install it alongside Cylon:

$ npm install cylon-api-mqtt

How to Use

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

'use strict';

var Cylon = require('cylon');

  name: 'cybot',

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

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

  work: function() {
    // Add your robot code here,
    // for this simple blink example
    // we'll interacting with the
    // robot through the 'led' device.

// ensure you install the API plugin first:
// $ npm install cylon-api-socket-io
  broker: 'mqtt://',
  prefix: 'cybot', // Optional


How to Connect

Once you have added the api to your Cylon.js code, and your robots are up and running, you can connect using MQTT, you need to subscribe to the topics you want to receive info for and publish the ones that execute commands in your robot.

'use strict';

var mqtt    = require('mqtt');
var client  = mqtt.connect('mqtt://');

client.on('message', function (topic, data) {
  data = (!!data) ? JSON.parse(data) : data;

  console.log('topic ==>', topic.toString());
  console.log('payload ==>', data);



setInterval(function() {
    JSON.stringify({ param1: 'uno' }));
}, 2000);