Node.js is used to build a network and a server-side application. We can also build web applications using Node.js. In this section, I will introduce you to how to use Node.js on Raspberry Pi. Then, use it to control sensor or actuator devices. The last task is to show how to publish sensor or actuator to be controlled via a browser or a mobile Android application. For further information about Node.js, you can visit the official Node.js website at http://www.nodejs.org.
To install Node.js runtime on Raspberry Pi, assuming that you use Raspbian OS, you can type the following commands in the terminal:
$ sudo apt-get update $ sudo apt-get install nodejs
To verify the Node.js program, you can type the following command:
$ nodejs -v
You can also install Node.js using Adafruit's Raspberry Pi package repository. Type the following commands:
$ curl -sLS https://apt.adafruit.com/add | sudo bash $ sudo apt-get install node
After the installation, you can type the following command...