Using Phidgets on a Raspberry Pi 2

Hello Makers,
In this instructable I will be showing you how to prepare a Raspberry Pi2 for use with a Phidgets Interfacekit 8/8/8

The Products from Phidgets allow you to connect sensors an actuators to your pc/pi/mac through the usb port. Most of the sensors do not require any soldering.

http://www.phidgets.com/

There are plenty of tutorials on how to prepare your Raspberry Pi, so I will skip that part.

I will be using the Raspbian – Debian Wheezy – Release date: 2015-05-05

I will assume that you have installed your Raspbian and know how to use the commandline.

I will be installing the phidgets libraries, the phidgets webservice and Nodejs. Finally I will show a very simple nodejs script to read an analog sensor, in my case a rotary encoder ( a potentiometer).Using Phidgets on a Raspberry Pi 2

Step 1: Step 1: installing and compiling the Phidget Libraries

All Italic lines are commands in the shell.

First of all make sure that you have updated your pi2

sudo apt-get update
sudo apt-get upgrade

Because phidgets communicate via usb, libphidgets needs to have liubs-dev installed.

sudo apt-get install libusb-dev

make sure your are in your home-directory

cd /home/pi

make a directory where you will store some downloaded filee

mkdir phidgets
cd phidgets

now grab the libphidget libraries and unpack them

wget http://www.phidgets.com/downloads/libraries/libph…

tar zxf libphidget.tar.gz

next we will configure the libaries , compile and install them

cd libphidget-2.1.8.20150410
./configure
make
sudo make install

In theory your pi can now use the phidgetboards,
but we will go ahead and install the phidgetwebservice as well
The webservice will allow you to talk to your PhidgetBoards via the network.
First we get the needed files, unpack and compile and install them

wget http://www.phidgets.com/downloads/libraries/phidg…
tar zxf phidgetwebservice.tar.gz
cd phidgetwebservice-2.1.8.20150410/
./configure
make
sudo make install

Now lets start the webservice in the background

sudo phidgetwebservice21 -n myphidgetName &

Step 2: Step 2: Attaching the phidgetboard and sensor

Attach a PhidgetInterfaceKit 8/8/8 via usb and connect an analog sensor to it.
I am using a potentiometer that I had left. It has different wiring from the phidget sensors so be careful.
If you have a sensor from Phidgets just connect the cable to one of the black analog ports.

That's it onto step 3Using Phidgets on a Raspberry Pi 2 schematic

Step 3: Step 3: Installing Nodejs and writing a script to read values

We need to install NodeJs. You will need version 0.10.36
Here is how you can install it. First go back to your home dir.

cd /home/pi

now get the proper nodejs package, and install it

wget http://node-arm.herokuapp.com/node_0.10.36_armhf….
sudo dpkg -i node_0.10.36_armhf.deb

you can check that you have installed it correctly by running

node –version

it should output

v0.10.36

now let's make a directory for our project

mkdir phidgettest
cd phidgettest

and initialize a nodejs project, just hit return a couple of times to get de default values,
they are not important at this moment

npm init

In order to communicate with the webservice we need a node-module called phidgetapi,
let's install it

npm install phidgetapi –save

 

 

For more detail: Using Phidgets on a Raspberry Pi 2


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top