I'm currently trying to use the PiFace Digital Board with my Raspberry Pi, I want to do this completely in javascript and Node Js. I have found that there is a piface-node module for Node Js and have installed it.

I now am trying out the example scripts that have written by the maker of this module, for some reason it isn't working. I am wonder if anyone has had any experience with this module and can point me in the right direction.

I navigate to the directory:

pi@raspberrypi ~/fyp/Node Js/node_modules/piface-node $ cd examples/
pi@raspberrypi ~/fyp/Node Js/node_modules/piface-node/examples $ ls
EventBus.js  pfio.input.changed.js  pfio.inputs.changed.js
example.js   pfio.input.hold.js     pfio.output.echo.js

Run this line:

pi@raspberrypi ~/fyp/Node Js/node_modules/piface-node/examples $ node pfio.input.changed.js

Then I get these errors:

ERROR: Can not open deviceERROR: Can not send SPI messageBad file descriptor
{ '0': 'pfio.inputs.changed', '1': 222, '2': 0 }
ERROR: Can not send SPI messageBad file descriptor
ERROR: Can not send SPI messageBad file descriptor
{ '0': 'pfio.inputs.changed', '1': 220, '2': 222 }
{ '0': 'pfio.input.changed', '1': 1, '2': false }
ERROR: Can not send SPI messageBad file descriptor

The Pi is the top range one, and it's getting powered from the plug rather than a USB port. So I assume that power isn't an issue.

I just want to get some lights flashing, and get some push buttons showing they've been clicked in the node output.


2 Answers 2


piface-node is pretty much a pass-through to the C libraries, so I'm not 100% familiar with all the error messages and why they happen. But, I'd look at these two things:

1. Do you have the SPI driver enabled?

(from: http://www.farnell.com/datasheets/1684425.pdf)

$ sudo nano /etc/modprobe.d/raspi-blacklist.conf

Insert a hash (#) at the beginning of the line containing spi-bcm2708, so it reads:


Save and reboot.

2. Do you have the correct permissions to the SPI device?

$ sudo apt-get update
$ sudo apt-get install automake libtool git
$ git clone https://github.com/thomasmacpherson/piface.git
$ cd piface/c
$ ./autogen.sh && ./configure && make && sudo make install
$ sudo ldconfig
$ cd ../scripts
$ sudo ./spidev-setup


example.js is the starting point for the example application, so give this a try:

pi@raspberrypi ~/fyp/Node Js/node_modules/piface-node/examples $ node example.js
  • I looked in example js and there only 3 requires. But i will give it ago. Commented Nov 13, 2013 at 16:39
  • You're welcome, @No1_Melman ! Everything in the example application is modular and decoupled: most of the components don't even know that the other ones exist. They only communicate through the EventBus. All that example.js does is start up those modules.
    – darrylh
    Commented Nov 13, 2013 at 19:19
  • I've updated the README.md (at least in the Git repository) to reflect the answers to your question. (github.com/darrylhodgins/piface-node)
    – darrylh
    Commented Nov 13, 2013 at 19:30

I pushed an updated wrapper for PiFace and NodeJS:

npm install piface

more info at https://github.com/ced-dev/piface

works with NodeJS 4.0+ and 5.0+

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.