Orange Pi Zero and Node.js

Zápisník experimentátora

Hierarchy: Orange Pi

In this article, we'll install the Node.js on Orange Pi Zero. This program allows you to create server applications using Javascript. That's exactly what we want to do with Orange Pi Zero. Create a simple server to which we connect using Arduino or ESP8266.

Used parts

We will need the following components:

  • Orange Pi Zero (link) - I use the version with 512 MB of RAM.
  • SD card - You need to use the Class 10 SD card. You need a size of 8 - 16 GB. The Armbian operating system must be installed on the SD card. I have used the version of Armbian 5.30, Debian Jessie 3.4.113.
  • Power supply with micro USB connector - At home you will surely have a mobile phone charger. Orange Pi Zero does not need a special power supply. Just check whether it is able to deliver 1.5 - 2 A.
  • Ethernet cable or Wi-Fi - This depends on how you set Orange Pi Zero. Connecting to a router via an Ethernet cable is the simplest way. If you have set up Wi-Fi, you can have your Orange Pi Zero placed anywhere in the apartment.

Installing Node.js

Node.js can be found on this homepage. From the site, you can install the development environment directly to your computer, and there are a few tutorials to help you get into the issue. Javascript syntax is very similar to C++, therefore, for you to understand the examples should not be harder than writing the programs for Arduino.

Armbian is an operating system derived from Debian distribution. Therefore, we will use the description in the installation manual of the Node.js. Connect via SSH to your Orange Pi Zero and type the following two lines in the console. This will install Node.js version 6.X.

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs

You can also install the most up-to-date version of 8.X.

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs

The current version of your installed Node.js and npm package, you'll find using commands.

node -v
npm -v

The first program in Node.js

It is a tradition that every language has its Hello world. You can also use my examples.

git clone https://github.com/roboulbricht/node.js-tests
ls
cd Node.js-tests
cd 01-hello-world-http
npm install
node hello.js

Then connect with your browser to http://192.168.0.73:3000/ (replace your IP address with your Orange Pi Zero address) and see the result. Armbian, by default, allows access to any port, so you will immediately see the result.


24.09.2017


Menu