Skip to content

Running on a Raspberry Pi

mackrauss edited this page Nov 28, 2012 · 6 revisions

Notes

  • Default serialport path for Arduino connected via USB seems to be /dev/ttyUSB0 or /dev/ttyACM0
  • If node doesn't seem to be communicating with the Arduino, try this:
    1. apt-get install setserial
    2. setserial /dev/ttyUSB0 spd_hi or setserial /dev/ttyACM0 spd_hi (depending on which tty the Arduino is showing up as)

Installing node-serialport on a Pi

After npm install, in the root rock_paper_awesome directory:

Manually compile serialport native bindings

This only works with serialport 1.0.6 — does NOT work with 1.0.7 or later

  1. cd node_modules/serialport
  2. node_modules/node-gyp/bin/node-gyp.js configure binding.gyp
  3. node_modules/node-gyp/bin/node-gyp.js build
  4. node_modules/node-gyp/bin/node-gyp.js install
Manually compile node-expact native bindings
  1. cd ../node-xmpp/node_modules/node-expat
  2. ../../../node-gyp/bin/node-gyp.js configure
  3. ../../../node-gyp/bin/node-gyp.js build
  4. ../../../node-gyp/bin/node-gyp.js install
Using the latest version of node.js

If you are installing node.js from the Debian apt repository with sudo apt-get install nodejs you will end up with a node.js server in version 0.6.x This is fine, but I seems that using the latest node.js version will make the install of the dependencies much easier. With 0.8.15 I was able to cd into the RPA directory and install all the dependencies by typing npm install. Even the node-gyp rebuild of the serialport node.js module was done automatically.

Installing node.js from source is explained in this article: http://www.raspberrypi.org/phpBB3/viewtopic.php?f=34&t=18775 and is done as follows:

  • wget http://nodejs.org/dist/v0.8.15/node-v0.8.15.tar.gz
  • tar xzvf node-v0.8.15.tar.gz
  • cd node-v0.8.15
  • ./configure
  • Warning the following command will take a long time (~2h). Maybe run it in a screen session
  • make
  • sudo make install

If you want to run awesome.js as a service you can use forever for node.js. Make sure to install forever globally by using the -g switch.

sudo npm install -g forever

Starting RPA as a background service can easily be done by issuing the following command

forever start path/to/rock_paper_awesome/awesome.js

Check that process is running with ps ax | grep node and stop the service by issuing

forever stop path/to/rock_paper_awesome/awesome.js