The Internet of Things applied to robotics: what are NodeBots?

5 min reading
26 October 2015
The Internet of Things applied to robotics: what are NodeBots?
The Internet of Things applied to robotics: what are NodeBots?

BBVA API Market

JavaScript is cool. And that's no coincidence. The day has dawned in which a developer with extensive knowledge in this programming language can do everything: front-end and  back-end projects, database and server management… and now also has an opportunity to be part of what is known as the Internet of Things. JavaScript is a jack of all trades.

There are currently numerous popularity lists that measure the performance of programming languages within the developer community: job opportunities, evolution of salary levels, number of projects on platforms like GitHub and StackOverFlow and much more. One of these lists is Trendyskills, which bases its rating on job offers. The graph shows the force of JavaScript, behind only Java.  

Within the world of the Internet of Things, robotics is one of the sectors that has caused the greatest stir among programming and technology enthusiasts. The use of open code hardware like Arduino or Raspberry Pi combined with opensource technologies in javascript to manage servers like Node.js has opened up a new world in the field of robots. So much so that the combination of Arduino and Node.js has spawned a type of bots known as NodeBots. This is robotics controlled with JavaScript.

The first NodeBots explorers

There are several names on the list of original explorers in the early days of NodeBots. The first two developers to reveal the possibilities of JavaScript for controlling robots were Nikolai Onken and Jörn Zaefferer during a talk at the JSConfEU in 2010. There is documentary record of that event on YouTube. This audiovisual gem shows how to use this programming language to control objects.

Their talk was so groundbreaking because it confirmed the role of JavaScript that had been signaled by other developers specializing in robotics: it is arguably the syntax that requires the least effort and lines of code to make the so-called Internet of Things a reality. The premise of their talk was that the world of connected objects is based on two single lines of code: 

$("livingroom").bind("motion", function() {
  $(this).find("lights").brightness("75%").dimAfter("120s"); });

The other name is Chris Williams, who that day in 2010 was among the audience at JSConf and heard the talk by Onken and Zaefferer. As Williams himself wrote in July 2012, his colleagues' words rekindled a sensation that had been niggling him for some time: the vast possibilities of JavaScript as a simple syntax for connecting objects. He was the creator of the most widely used javascript package for developing NodeBots, Node-SerialPort, which enables users to interact with a microcontroller through Node.js.

Julian Gautier and Rick Waldrom are next in this timeline of the first steps in the field of robotics with JavaScript.

Gautier is the father of the Firmata protocol, which allows communication with microcontrollers through a computer, tablet or mobile software. The most complete Firmata profile today is for the Arduino platform. Firmata has several client libraries in a number of languages in addition to Javascript: Processing, Python, Ruby, Perl, Clojure, Java, PHP and others.

Waldrom was the one to take the Firmata protocol and transform it into a robotics development framework in JavaScript and the Internet of Things called Johnny-Five. It is this framework that has allowed many robot programmers to endow their NodeBots with all the functionalities they enjoy today: movement, control of lights and sound and much more, using a microcontroller platform like Arduino or others and Node.js.

How to begin to set up NodeBots

The first step is to acquire an Arduino starter kit, which usually contains several components for robotics. There are some interesting packages on the market, from the company of the blue boards and from others:

– Genuino and Arduino Starter Kit. This package has several important components for different types of projects: USB, 9V battery, potentiometer, buttons, temperature and tilt sensors, several colored LED lights (white, red, green, yellow and blue), diodes, a motor and a servomotor, photoresistances, condensers, opto-isolator, resistances with different ohms and more. 

– SparkFun Investors Kit. This small piece of equipment is similar to Arduino's in its components. It has buttons, several colored LED lights, a motor and a servomotor, diodes, potentiometer, temperature and light sensors, resistances and USB cables and more This is an attractive kit for a number of hardware projects.

There are other component packages that can be used to make NodeBots: the Experimenter’s Kit for Arduino, Seeed ARDX – the starter kit for Arduino and the Adafruit ARDX Experimentation Kit for Arduino. The prices range between 65 and 90 dollars. Some are more comprehensive than others.

How to go from the kit to the Internet of Things with Node.js

These are the steps you need to begin to set up NodeBots:

Instal Node.js. The installation procedure depends on the type of operating system in each machine (Windows, Mac OSX, Linux, Ubuntu… ). When you log on to the official page of Node.js, it automatically recognizes the type of OS you have and starts the installation. In the case of Windows, you download and run the .msi file. 

– The developer Anna Gerber has a guide on GitHub, under license from MIT, on how to develop NodeBots with Node.js. Description and code.

– Download the Arduino integrated developer environment. The current version is 1.6.5., available for the Windows, Mac OSX and Linux operating systems. It's a framework written in Java and based on Processing.

– Connect the Arduino-compatible microcontroller with the USB.

– Launch the Arduino IDE and open the Firmata protocol through the following menu route: File > Examples > Firmata > StandardFirmata.

– Select the type of Arduino board on the route Tools > Board.

– Choose a port for the board in Tools > Serial Port > (Arduino port).

– Upload the Firmata protocol to Arduino in File > Upload.

– This process also installs the development framework Johnny-Five. Any code can run within the node-ardx directory.

– Now you can develop the web application to control the movements of the NodeBot made with Arduino, Node.js and Johnny-Five.

– The server-side JavaScript code, made with Node.js and Express.js (specific developer framework for Node.js) would be something like this:  

var express = require('express');
var app = express();
var io = require('socket.io')(app.listen(8081));
var five = require('johnny-five');
app.use(express.static(__dirname + '/app'));
app.get('/', function (res) {
           res.sendfile('/index.html');
});
var board = new five.Board({
           repl:false
});

The developer page Sitepoint has a step-by-step guide with the code necessary to set up a motor-bot controlled from a web app.

NodeBot development is currently a genuine international craze. The community holds meetings all over the world and even has a date to celebrate International NodeBots Day on 25 July. You can follow all the new developments through the profile @nodbotsday on Twitter, their profile at GitHub or through the NodeBots team. Experiment!

Follow us on @BBVAAPIMarket

It may interest you