Ghost Themes
SimpleChat.Support - Open Source Live Chat App
Meteor meets Arduino and Cylon
words - read.

Meteor meets Arduino and Cylon

Some time ago I was able to play with my first Arduino ( board. It was just for fun and nothing else. My main objective was to test JavaScript programming for robotic purposes. The fact that I know Meteor.js led to my attempt to join the forces of Meteor.js, Arduino and Cylon.js.

Everybody has heard about Arduino but what is Cylon.js?

Quoting the official website ( Cylon.js is a „next generation robotics framework with support for 35 different platforms”. This is really cool because you get one API to rule them all ;) And what are they? With Cylon.js you can program and control many devices like Arduino, mentioned above, but also ARDrone, Beaglebone Black, Raspberry Pi, Tessel and even Leap Motion. You can find a full list here:
There is also full documentation for each device. We will talk about Arduino here. I also want to test ARDrone with Cylon.js and Meteor.js but this will come in the future. Of course you can play with any other device. Beaglebone Black, Arduino Yun or Tessel are very promising. I definitely will check those out in the future. If you want to play with Meteor and some other device than Arduino, this article could be a very good introduction on how to build your own package for a particular device. Also, if you want to use Arduino with Meteor, you definitely should read this.

Ok, let’s start..

First of all we need to connect our Arduino board. This is very simple with one tool called ( Arduino needs to be connected by USB cable and it needs to have Firmata firmware uploaded (we need to do this only once). How can you do this? It is sometimes problematic with 'sudo' privileges. In fact I need to manage the best way to do this because I have ended up needing to run Meteor with 'sudo' which is not very cool for me. If you have any tips, just drop me a note. But, what we need to do is install the cylon-firmata npm package and then install Gort which will be responsible for uploading firmata to Arduino. With Gort you can scan your ports and upload firmata to the one where Arduino is connected. In default it should be /dev/ttyACM0 on Linux and /dev/tty.usbmodem1421 on OSX. The best explanation is here: If you have problems with installing Gort, just download it and run it from its folder by './gort' command. I am not sure if it is a good idea to install cylon-firmata globally especially when we will depend on it in Meteor packages, but in case of any problems you can try with this too.
If you manage to get it working you can first go through a very simple test which is described here: Just put your LED into pin 13 on the Arduino board. You will find how it should look on the Internet. Then just copy the code and save it in name_it.js file. You can run it by node name_it.js and your LED should be blinking.

My Arduino board is connected and my simple Node program works.. What's next?

Now we can prepare our test project for Meteor use case. You will need Arduino Uno board, one Breadboard (example:, 2 LED lights, 5 jumper wires (male) (example: and 2 resistors (example: See the sketch below and you will find how to connect it all.

Arduino Board

Now you can create your Meteor project and add packages (or dowload demo app - read below):

$ meteor create arduino-project
$ cd arduino-project
$ meteor add juliancwirko:arduino-cylon
$ meteor add juliancwirko:caprica

Packages GitHub repos:

Then you need to set up your Cylon.js config on the server side in Meteor startup function. You can find an example in the demo app.

Instead of creating a new project you can also clone the demo app from here: There you can find all that you need to run our example. You can see cylon.js file here: this is the config we want. If you want to read more about this config you should go to the Cylon.js website. You will find more explanations for all drivers like LED, Servo, Button etc. What is new in this config is the section with commands. It is needed for the 'Caprica' admin panel. It will autodetect these commands and show you on the screen. These are simple functions you can write. I think that cylon.js config is readable and you will figure it out. If you have any questions don't hesitate to ask.

After you clone the demo app you need to connect your Arduino board and run the app by writing 'meteor' command (in my case I need to do it with sudo). There should be some info about initialization and starting devices in the server side console. Then you can go to the default server URL which is localhost:3000 and you will see the 'caprica' admin panel. It should show you your connected Cylons with all the configured commands. See the demo movie below. (you can connect more than one Arduino board or for example Arduino and ARDrone and it will all show up in the Caprica admin panel demo)


Caprica demo video


Ok, but what else can I do?

There are endless possibilities and Meteor is really cool for this job. Its reactive data features are exactly what you need when working with Internet of Things. You can make use of Meteor Mongo and Minimongo reactive sync. You can build all kind of sensor based devices and write all the data into Meteor collections. You can also listen for changes from third party services and program your Arduino to respond to these changes. This is very simple with Meteor because you don't have to think about this reactive syncing at all. It is done automatically for you so you can focus on the device programming and not how to send data from one to another.

Future of these packages?

Like I said in the beginning, this is only for fun but I plan to build something cool. I think these packages will be improved for when I need them for more complicated projects. I also want to build some kind of Meteor API based on Iron Router or even DDP. I want to learn more about the Cylon.js events. It is a very cool feature and I think it will work well with Meteor. In the future there should be also a ARDrone package. I encourage you to help me with these packages :) Pull Requests are welcomed.


comments powered by Disqus