TNS
VOXPOP
What’s Slowing You Down?
What is your biggest inhibitor to shipping software faster?
Complicated codebase and technical debt.
0%
QA, writing tests, and debugging.
0%
Waiting for PR review or stakeholder approval.
0%
I'm always waiting due to long build times.
0%
Rework due to unclear or incomplete specifications.
0%
Inadequate tooling or infrastructure.
0%
Other.
0%
Software Development / Tech Culture

Getting Started With Node.js on the Hummingboard, a Raspberry Pi Clone

Feb 22nd, 2015 10:15am by
Featued image for: Getting Started With Node.js on the Hummingboard, a Raspberry Pi Clone

Javascript’s event-driven model of execution lends itself well to server-side Internet of Things applications, particularly on nanoLinux devices, like the Raspberry Pi or a Hummingboard clone. I have a couple of Hummingboards and they are robust little devices. Since I’m just putting my toe in the Javascript water, the first order of business is that of installation and a quick check to see if I can put something up on a Web page. In a subsequent article I might expand the exploration into more complex Web examples and maybe try some input/output on the GPIO pins of the board.

Installation

Installation is fairly straightforward using the command line. I used a Hummingboard-i2eX with the i.MX6 Dual (2 core) processor, 1 GB of 64-bit 1066 Mbps memory and Debian Linux version 3.0.35. The setup also has a powered 4 port hub, a Logitech wireless keyboard/mousepad and an EdiMax 802.11n USB wireless dongle. Video is handled through the standard HDMI cable out to a Sanyo big screen. Raspberry Pis and their clones all seem pretty sensitive to power requirements, so a powered hub is pretty much a necessity. Use a 5-volt 2 amp wall wart for the Pi and Hummingboard, with a good USB cable, to head off problems.

I followed the directions on the justplugin Web site to load node.js on my Hummingboard device. Here are the steps with a bit of commentary:

1. Make a new directory to hold the downloaded nodejs files.


2. Fetch node.js from the Internet.


3. Compile and build the node.js programs.


Even with the dual-core Hummingboard, a fairly fast Internet connection and 1 GB of memory compiling and building the programs, it took about 40 minutes.

4. Install the program on the Hummingboard system.


5. Reboot the Hummingboard.


6. Determine the version of node.js and the module installation programs. These commands also verify that everything is working.

An Exceedingly Simple Example

The Web has tons of examples on how you can get started using node.js with a Raspberry Pi-based machine. I found a little program that simply posts “hello world” to a browser screen using the node.js server. Check the howtonode Web site for complete details and a handful of additional script examples.

1. Here’s the hello-node script from the howtonode site.


2. Put the text in a file and call it hello-node.js, using your favorite command line editor.

3. Start the server and run the script with the following command line:


You’ll get a message that says the server is running on the localhost (127.0.0.1:8000).

4. Punch that IP into your Pi’s browser and the “hello world” message should appear at the top of the screen. You can also see the page from other machines, on the same network by using the IP of Hummingboard. Find it with ifconfig.

In my case, I could see the message from my XFCE Linux Asus notebook when I pointed to the 192.168.1.111:8000 (address of the Hummingboard, on my LAN), in the Chrome browser.

Conclusion

I was happy to find out that it only takes a moderate amount of effort to get node.js running on a Raspberry Pi-based nanoLinux machine. There’s a whole lot of information on the Web about Javascript and it’s a popular language. I’ll take a look at accessing the GPIO pins in a future story.

Featured image via Flickr Creative Commons.

Group Created with Sketch.
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.