Node.js and The Internet of Things

- Fire development, Node.js

Node.js as the best tool for The Internet of Things development

Smart companies never stands still trying to determine new technologies and leverage them. Therefore, as tech enthusiasts, we always try to dig something interesting; and this time our attention is focused on two modern trends: The Internet of Things and Node.js. Each one provides tons of new opportunities when used separately, but both can be combined within a single system as well. Below, we explain how these phenomenons are used together, demonstrate why Node.js is ideal for the creation of the  Internet of Things ecosystems, and talk about some Node-based services related to the IoT development.

'

Unfortunately, most IoT products do not provide a unified experience for communicating between business systems and appropriate devices. Moreover, some of modern IoT technologies are very expensive, but still don’t offer enough flexibility and agility. Therefore, developers are looking for new ways to reduce the price of their products and make them more useful and feature-rich.

That’s where Node.js with its features comes in. The popular platform is open source, user-friendly, and well-suited for addressing the needs of IoT apps. Since it is based on Google’s V8, an open source JavaScript engine, Node is known as fast, scalable, and effective tool for the development of data-intensive, real-time apps serving the Internet of Things. Besides, it provides effective and secure communications as well as interactivity, so  Node.js APIs suits so well to the IoT model.

It is also necessary to mention a wide variety of Node.js tools. Such frameworks as Hapi, Express, or Restify have essentially changed the process of APIs development in Node.js. Even without a huge experience and any powerful pre-built solutions, it takes only a few lines of code and a short amount of time to create a simple API.

As for IoT devices, all possible sensors, wearables, and beacons, they generate a plethora of requests. Not every platform can handle such a great amount of data, but Node.js can. It is well-suited for managing these requests, since the platform relies on stream instances which are basically Unix pipes. Streams are monitored and processed very efficiently, can be writable, readable, or both, and are easy to use. Due to a streaming nature, Node.js provides users with the ability to stream data directly to its destination or pipe requests to each other without caching or using temporary data. As a result, you get a stream from one place to another which is crucial for the Internet of Thing, since such approach helps to reduce the usage of resources significantly.

Node.js community is another reason to use the platform with the IoT. You might have noticed that the Node.js npm repository contains dozens of packages aimed at the Internet of Things devices and apps. For instance, there are 80+ packages for the Arduino controller, more than 10 for Bluetooth Low Power, and a lot of tools for Pebble, Fitbit, and other wearables.

Very low resource requirements, proven performance, and the simplicity of use make Node.js the number-one tool for creating IoT apps. Here are some advices for developing an IoT API-first architecture with Node.js. First of all, you should rely on several simple apps instead of a complex one. Use small independent components connected via APIs, and you will provide your system with robust scalability and failover. If one instance crashes, the whole system will be still available. Besides, an API-based architecture makes it possible to produce a clean and extensible design.

Thus, Node.js provides much wider opportunities for building IoT applications than its counterparts. Someone still uses Java to master the Internet of Things, but this approach has too much drawbacks in comparison with Node.js. Therefore, we propose you to examine the following Node.js services related to the IoT.

Node-RED

Node-RED - Node.js tool for the Internet of Things development

Node-RED is a revolutionary Node.js tool for connecting hardware devices, APIs, and online services within one system. The service provides a browser-based flow editor which simplifies wiring flows with the aid of nodes. Flows can be deployed to the runtime within just one click; and JavaScript functions can be developed using a rich text editor. Besides, Node-RED offers a built-in library designed to save functions, templates, and flows for further using.

The lightweight Node.js runtime provides the full advantage of event-driven, non-blocking nature and make it possible to write Internet of Things applications for a low-cost hardware and cloud usage.

IoT development with Node.js: Node-RED

As for available tools, the Node.js npm repository offers more than 120,000 modules; and all of them are available through Node-RED platform. It is also necessary to mention, that  Node-RED stores flows via JSON, so all your IoT projects can be easily shared with others.

Cylon.js

Cylon.js - Node.js tool for the Internet of Things development

Cylon.js is a powerful JavaScript tool for the Internet of Things, physical computing, and robotics. The framework makes it incredibly easy to command devices; and all you need is the cylon NPM module. Cylon.js supports a lot of robotics and physical computing systems as well as various software platforms. Some of them are listed below:

  • ARDrone
  • Arduino YUN
  • Beaglebone Black
  • BLE
  • Crazyflie
  • Imp
  • Intel Galileo
  • Intel IoT Analytics
  • Joystick
  • Leap Motion
  • Nest
  • Pebble
  • Raspberry Pi
  • Salesforce
  • WICED Sense

Besides, there are platforms developed by Cylon users: Parrot Rolling Spider, iBeacon, PCDuino, and Belkin Wemo.

It is also worth mentioning that Cylon.js can be run directly in your browser with the browserify NPM module, within a Chrome connected app, or a PhoneGap mobile app. The platform is heavily based on an API plugin system and uses the Gort toolkit, so you can utilize the command line. Moreover, there is a separate CLI tool for generating new modules, robots, and drivers within Cylon.

Zetta

IoT development with Node.js: Zetta

Being an open source API-First Internet of Things platform built on Node.js, Zetta provides all the necessary tools for creating IoT servers that run across geo-distributed computers and in the cloud. The platform combines WebSockets, REST APIs, and reactive programming for combining various devices and data-intensive, real-time apps into complex IoT systems.

Zetta allows you to observe and react to the behavior of your devices and systems in code and via visualization tools. Besides, you can stream data into Splunk or other machine analytics platforms.

With the help of Zetta, you will be able to assemble all possible applications together into a complex adaptive system that operates in the physical world of wearable computing, home automation, smart transportation, etc. Its servers run in the cloud, on single-board computers, or on PCs; and it turns any device into an API, providing you with the ability to connect everything together. Thus, Zetta is another prominent IoT Node.JS example.

deviceJS

deviceJS - Node.js tool for the Internet of Things development

Being a JavaScript engine for the Internet of Things, deviceJS is dubbed jQuery for IoT. As the previous tools, it is built on Node.js and provides endless opportunities for creating IoT applications and systems. The platform provides you with the ability to build node.js/io.js web apps for controlling and listening smart devices. deviceJS automatically detects a plethora of hardware components providing hooks for event changes. Besides, it supports many IoT frameworks significantly simplifying the creation of smart environments and automated systems.

IoT development with Node.js: deviceJS

deviceJS makes it possible to connect Node.js Web apps with smart devices of any brand or protocol into a single system with just one language. Or you can build your own system for controlling the Internet of Things as you wish.

Tessel 2

Tessel 2 - Node.js tool for the Internet of Things development

Tessel 2 is an open source software and hardware solution which provides everything you need to get up and running with the Internet of Things systems. It introduces the ability to add sensors and actuators in one step, use such peripherals as cameras and 3G/4G dongles, and program your systems wirelessly. Besides, Tessel 2 offers an ultra-reliable wired connection, fast program execution, and plenty of space for your code. It is also necessary to draw your attention to power and tethered programming, realtime I/O, and advanced power management. Discover some crazy Tessel projects in the video below:

Each module related to Tessel 2 has an open source library on NPM and a dedicated documentation. You just need to connect, npm install, and write a few lines of code to get started. Thus, the system offers endless combinations of modules for creating new devices; and you can use your favorite text editor and libraries to program hardware component of Tessel 2.

Mosca

IoT development with Node.js: Mosca

Mosca is a Node.js MQTT broker, which can be used as a standalone module or embedded in another Node.js application. In its turn MQTT is a simple and lightweight publish/subscribe connectivity protocol for Internet of Things and machine-to-machine systems. It is designed with constrained devices and unreliable networks in mind, so resource requirements are minimized, which makes MQTT ideal for the Internet of Things world of connected devices. As for Mosca, it simplifies the development based on the protocol, being another good example of Node.js usage in the IoT.

Johnny-Five

Johnny-Five - Node.js tool for the Internet of Things development

Being the original JavaScript Robotics programming framework released in 2012, Johnny-Five also requires using Node.js. This tool for running Internet of Things projects is maintained by a community of both software developers and hardware engineers; as a result, we can see another robust and extensible ecosystem. Johnny-Five suits the best for Arduino-compatible Boards, since it is Firmata based Arduino Framework, but it also provides platform-specific IO Plugins for non-Arduino projects, which communicates with any hardware in whatever language.

Node-Serialport

IoT development with Node.js: Node-Serialport

This is a Node.js package for accessing serial ports with the ability to read and write. It is one step towards a world where users control lights, security systems, robots, or even blenders via JavaScript. Node-serialport provides a very simple interface to the low level serial port code. As a result, you can easily program X10 wireless communications, Arduino chipsets, as well as Z-Wave and Zigbee standards, developing complex Internet of Things environments. The package is another proof of Node.js superiority in the IoT development.

USB Library for Node.JS

USB Library for Node.js - Node.js tool for the Internet of Things development

Node.JS USB library is another important thing for the Internet of Things ecosystem, since it is responsible for communicating with USB devices in JavaScript or CoffeeScript. In order to achieve better efficiency, the library is based on the libusb’s asynchronous API. Besides, it provides a stream API for continuously streaming events and data.

i2c-bus

IoT development with Node.js: i2c-bus

This package provides an I2C serial bus access via io.js or Node.js. It supports the following Linux boards: Raspberry Pi (1 and 2), BeagleBone (original and Black), and Intel Edison. It is also necessary to mention that all methods have asynchronous and synchronous forms. Thus, i2c-bus is another reliable tool for building IoT systems with Node.js.

Conclusion

In order to effectively exploit the IoT developers must consider products and processes that will help them build useful, user-friendly, and secure solutions; and Node.js is a tool that everyone can leverage to design leading Internet of Things devices, applications, and ecosystems. For further information on IoT with Node.js, check the below video.

'