while (things) do {fall apart;}

My adventures in computer programming

Node.js on a Raspberry Pi

I worked for a theatre company that wanted to use a projector mounted inside a 3D structure attached to a zipline that floats above the audience. One long cable for power and another long ethernet cable were attached to the ‘pod’. Inside the pod was a projector, a convex mirror in the shape of a cross-section of a sphere, and a raspberry pi.

From our technician booth our interactive artist sent live visuals controlled and created by visual programmings software VVVVV to the projector. How did we enable this over an ethernet connection?

It seemed like an easy way to do this was with a Raspberry Pi mounted inside the pod. It received a stream of visual code via ethernet and then sent to omxplayer, a piece of linux software that can stream video to the Pi’s video output.

We wanted to make sure we had full control over the Raspberry Pi in the case of any breakage in the connection or timeouts, etc. Node.js turned out to be an easy way to accomplish this.

Some of the powers of Node.js

  • Control GPIO pins on the Raspberry Pi for embedded electronics
  • Control command line processes like omxplayer for video playback
  • Issue system commands like restart, shutdown, etc.
  • Spin up a simple web server for sending two-way communications written entirely in Javascript

I wrote code to start a Node server running on the Pi. I could start and stop the server with an SSH connection between my machine and the Pi. The node server created a webpage that the interactive artist could open in a browser. The page had buttons to restart the pi, test a video connection, and send a movie file to it for playback.

Ultimately we ended up controlling the Pi over SSH rather than using the Node server. This was simpler and easier to set up.

I look forward to using Node.js in future projects! I like that it’s super fast in terms of multi-threaded request handling and throughput.


Share