Running Node.js on Arduino Yun

Arduino Yun is a great device once you learn how to use it correctly. Microcontrollers like the Atmel-ICs used in all nearly all Arduino compatible devices haven’t a lot of power or memory to Internet-Traffic. Of course they can, there are libraries and modules out there that will transform your little Arduino in a full-fledged Internet of Things device, but you will not have a lot of fun running it.

I.e. a typically RESTFul Web service will deliver so much JSON-Code that even a slightly more complex response will blow the memory of your Arduino.

Arduino Yun, and a few others like DigiX (sold in Germany for example by cboden) or Udoo solve this problem by merging the best of both worlds onto one device. Imaging a Raspberry Pi with an Arduino. If you want to know more about the difference between those two I have a small introduction on both devices.

Arduino Yun packs a full-fledged rather powerful Linux-machine onto an Arduino Leonardo. A so-called bridge allows the Linux part to talk to the sketch, and the sketch is allowed to run the Linux shell. This way you can use everything that has ever been build for Linux, the whole Internet-Stack, and the Arduino Sketch controls all that.

The previous example of running a rather complex RESTFul-Webservice, the sketch would run a Python, PHP, Node.js-Script on the Linux side that will request the data, process them, and delivers back only the really useful things to the micro controller. This way memory is now blown.

Since the latest software-update for Yun (see here on how to update your Yun) you are allowed to run Node.js on the Linux side of your Yun. That way you have a very powerful combination as Node.js is basically exactly build for that: Handling events in a very easy and transparent way. I have never really loved to work in Python, so I have been very pleased to know that I can write my Arduino Internet of Things Code in JavaScript using Node.js.

(more…)

Read More