Enginursday: JavaScript ... the future of IoT?

How JavaScript has evolved into a language supporting an entire ecosystem of devices

Favorited Favorite 2

alt text

IoT is growing faster than ever! In fact, it is growing faster than smartphones. “Computerworld” recently reported that U.S. Cellular carriers are adding more IoT connections to their networks than phones or tablets!

The article states that AT&T, which leads the area of connected cars, aims to reach 10 million car connections in the near future. Wow! Check out these statistics from industry expert Chetan Sharma.

According to Sharma's research, one-third of cellular companies' new device subscriptions are cars!

Why so many cars with cellular connections?

  • A cellular connection makes the car connected to a centralized ecosystem of cars. This helps the manufacturer gain information about the cars they roll out and make improvements to future models.
  • The traffic data from all the cars can be used to provide truly real-time updates, meaning your car can navigate and get route updates like traffic and detours automatically without having to use your phone.
  • In case of emergencies or breakdowns, a connected car would come in handy in calling AAA or the appropriate authorities to your rescue.

The explosion of connected cars is one of many indicators of the compelling nature of IoT and how fast it is growing! Today, we will talk about the role JavaScript, and particularly Node.js, is playing in making the development of IoT applications easier than ever -- not only for hobbyists but for major corporations.

How JavaScript is Becoming the Language of IoT

alt text

JavaScript was built for the Web. Its primary use was to make the web pages dynamic and more interactive. No one would have thought that it could be so much more than that.

JS did one main thing: provide the ability to serve an interactive I/O web page without lagging or hanging. This was possible due to the event/callback model of JS. Old programming languages never had this feature.

Other characteristics of JavaScript like its ubiquitous web-presence, a very big community of developers and its is freaking easy to learn and write code in! These things make JS one of the most suited language to be leveraged for the development of the Internet of Things.

The way IoT is evolving today is not so different from how the internet has evolved over the past decade. Check out this awesome infographic tracking JavaScript's journey into the future of IoT.

What is Node.js?

alt text

Source -- Nodejs.org

Node.js is a runtime built on the Chrome V8 JS engine, which was originally designed for running JavaScript in browsers. Node took off with the separation of the V8 engine from the browser and having an environment for building JS applications on your machine directly. 'Node' was written by Ryan Dahl in 2009.

In just a few years, Node.js has gained an active community of backers and developers. Numerous tools and modules are being developed leveraging the node runtime. It is important to note that node runs as a single thread but can still serve a large number of requests.

The node website states, "Node.js' package ecosystem, npm, is the largest ecosystem of open source libraries in the world." It is ever-growing with hobbyists, and big tech companies like Google and IBM are releasing their node-based applications now more than ever.

Why Node.js Can Change IoT as We Know It

We know that one of the hurdles Node.js faces is scalability. The I/O model that Node.js uses is event-driven and non-blocking, making it lightweight and efficient. These features of node are beneficial for IoT-related development.

Node is suited to handle a lot of request at the same time without issue. With our ability to gather and push data to the cloud growing exponentially, there are limitless possibilities. The humongous data cloud contains answers to the questions we dared not ask, and finding the needle in the haystack has become easier than ever! There is a dire need for an environment that not only supports scalability but also offers rapid and flexible application development. This fits the design objective of Node.js.

Another reason Node.js has seen rapid growth in IoT applications is the presence of an "active developer" community that is developing node-based APIs. Node has modules like Express and Restify, which can be used to create APIs in just a few lines of code, making rapid development possible.

One example of innovation in the early days of the Node.js community is NodeBots. When Chris Williams created the node-serialport module, it opened doors to JS developers for hardware creation and control. In late July, the world celebrated NodeBots Day, and the JS robotics and IoT platform Johnny-Five makes it easy for anyone to join the revolution!

alt text

NodeBots Unite! -- nodebots.io

Other node packages such as Cylon.js and Node-RED make it the perfect fit for IoT applications.

Big Players

JavaScript has proved to be a powerful tool, and not just for web development but for all sorts of application development. Samsung has developed a JS engine specifically for the Internet of Things called JerryScript. Samsung’s IoT.js, a framework specifically for IoT, is based off the JerryScript engine, making it an ultralight version of node.

JerryScript has been developed to be used with resource constraint devices (with less than 64 KB of RAM and less than 200 KB of Flash memory). It also supports on-device compilation and execution and could prove to be game changing for increasing interoperability among different platforms.

Other tech giants have not fallen behind. Microsoft has a JS engine called 'Chakra JS' as an alternative to get Node.js running on IoT devices using newer-generation ARM processors. Learn more.

IBM is pushing its limit for the development of IoT. The IBM Bluemix Platform integrates the cloud and different IBM APIs to build your next IoT app quickly. One particular tool -- Node-RED -- is the epitome of rapid and visual programming.

Node-RED

alt text

Source -- nodered.org

According to Datamation.com, Node-RED is a “visual tool for wiring the Internet of Things" that "simplifies the process of connecting IoT devices with APIs and online services." Built on Node.js, Node-RED is multiplatform -- running on Windows, OSX and Linux -- and includes a browser-based flow editor.

An initial version of Node-RED was released in late 2013 as an open source project, according to noderedguide.com. By 2014 it had built a small but very active developer community, which continues to grow.

alt text

An example Node-RED flow! -- m2m@IBM

In Node-RED, an application consists of one or more flows, and each flow represents connected nodes. There are different types of Nodes available for Node-RED by default, and more can be installed using npm.

Flows work by passing JSON messages along the nodes to get the desired result. Each node can be configured with the settings specific to the particular node.

What's really great about Node-RED is its agile nature. You can deploy the application, make changes and see them in action immediately!

The Graphical User Interface (GUI) is simple and intuitive, rendering it possible for everyone to use without much programming experience.

Node-RED is still a nascent technology, but it is rapidly being adopted by the maker community.

Where Do We Go from Here?

There are already IoT-compatible boards such as Raspberry Pi, Tessel 2, Intel Edison and BeagleBone Black, which can easily accommodate Node.js and the thousands of npm packages, including libraries for communication protocols such as HTTP, IFTTT, MQTT etc. Apart from these popular boards, there are hundreds of other IoT-based development boards on the market that are capable of utilizing node and its rich features.

Even smaller microcontrollers, especially ARM-based low-power embedded boards, will soon be compatible with Node.js, giving rise to endless possibilities.

The development of ultralightweight JS engines will help give tiny and low-power end-point devices a common platform to communicate and transmit data seamlessly to the cloud. Onboard compilation and execution will facilitate easy firmware updates over the air, reducing the cost.

JavaScript has the potential to become the language for IoT, but only time will tell. As of now, we can say one thing with confidence: that it's going to be one heck of a connected ride!


Comments 4 comments

  • meljr / about 8 years ago / 1

    Connected cars? You gotta know Big Brother is wanting in the back door -- your insurance company too. Kinda creepy.

  • RichardBronosky / about 8 years ago / 1

    It's surprising to me to read an article about JS in the IoT and find no mention of Espruino. http://www.espruino.com/ I've been a backer from the start. This community is doing amazing things with low power devices.

    • xorbit / about 8 years ago / 1

      Another +1! Gordon has done such excellent work with Espruino and is hardly recognized in the Maker community at large. I wish Sparkfun would take off their Arduino blinders and put more support behind modern efforts to make electronics easy.

    • Member #840301 / about 8 years ago / 1

      Big +1. It's so established and well supported, I really don't know why Jerryscript got the mention instead. Espruino is the eminent JavaScript-on-mcu solution by far. Someone's even just recently created node-red nodes that run on your espruino!

Related Posts

Recent Posts

Raspberry Pi SD Cards

Sweet as AI Pi

Tags


All Tags