Remote Control With Raspberry Pi and Phidget WebService

Enable your Raspberry to control relay, led, sensor and digital input remotely with Phidget WebService. "The Phidget WebService is a background process that broadcasts all events and data from a USB Phidget over the network: It uses link local addressing which allows you to use simple server names in your code. The link local addressing is provided by the programs Bonjour, avahi, or mDNSResponder, depending on your system, and the correct program is either installed already or with the Phidget libraries. You can listen to the Phidget data and control the Phidgets over the network using one or more computers."More info

You need a Raspberry with Raspbian preinstalled, a Phidgets IO Board, I use a 1011_0 - PhidgetInterfaceKit 2/2/2, a small usb Dongle with 2 Analog Inputs, 2 Digital Inputs and 2 Digital Outputs, two analog sensor, in this tutorial I use a 1133_0 - Sound Sensor and a 1142_0 - Light Sensor 1000 lux, two led connected to digital output, one toggle switch and a Miniature Magnetic Contact Switch connected to digital input.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Install Phidget Library

Update the packages with

sudo apt-get update
sudo apt-get upgrade
Install libusb (Library for programming USB applications without the knowledge of Linux kernel internals).
sudo apt-get install libusb-1.0-0-dev
download and install the Phidgets libraries.
tar zxvf libphidget.tar.gz
move in the decompressed folder, in this example
cd libphidget-

Remote control with raspberry Pi and Phidget WebService

From the main unpacked libraries directory, run:

this takes a long time, you can go get a coffee smiley
sudo make install

This will compile phidget21.h and place the library into your gcc path

Step 2: Install the WebService

Download the webservice

tar zxvf phidgetwebservice.tar.gz
move in the decompressed folder in this example
cd phidgetwebservice-
From the unpacked WebService source code directory, run:
sudo make install
This will compile the executable phidgetwebservice21 and place it into /usr/bin/phidgetwebservice21

Create a file to manage start and stop for the webservice

sudo nano /home/pi/phidgetwebservice
with this content
# Provides:          phidgetwebservice
# Required-Start:    $network $remote_fs
# Required-Stop:     $network $remote_fs
# Should-Start:      avahi
# Should-Stop:       avahi
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Phidget WebService
# Description:       Phidget WebService for controlling Phidgets over the network.
DESC="Phidget WebService"
# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0
# load config
[ -f $CFG ] && . $CFG
start() {
    [ -z "$pws_port" ] || OPTIONS="-p $pws_port "
    [ -z "$pws_password" ] || OPTIONS="$OPTIONS-P $pws_password "
    if [ -z "$pws_serverid" ]; then
        OPTIONS="$OPTIONS -n $( hostname )"
        OPTIONS="$OPTIONS -n $pws_serverid"
    echo -n "Starting $DESC: "
    start-stop-daemon -S -b -q -p $PIDFILE -m -x $DAEMON -- $OPTIONS && echo "OK" || echo "ALREADY RUNNING"
stop() {
    echo -n "Stopping $DESC: "
    start-stop-daemon -K -q -p $PIDFILE -x $DAEMON && echo "OK" || echo "NOT RUNNING"
case "$1" in
    sleep 1
    echo "Usage: $0 {start|stop|restart}"
exit 0
give it executable permission
sudo chmod -R 0755 /home/pi/phidgetwebservice
then try to start with command
sudo sh  phidgetwebservice start
To start the web service automatically
sudo mv /home/pi/phidgetwebservice /etc/init.d/phidgetwebservice
sudo insserv -d phidgetwebservice
reboot raspberry
sudo reboot

Step 3: Use It

Ok now we can control the 1011 remotely.

For Windows open the Phidgets control panel, in tab Web Service / Bonjour you can see all boards Phidgets connected to Raspberry

Remote control with Raspberry Pi and Phidget WebService

Double click on Phidget InterfaceKit 2/2/2 open this window, where you can read input analogic - digital and interact with output, turn on/off the leds

Remote control with Raspberry Pi and Phidget WebService

Remote control with Raspberry Pi and Phidget WebService

For Mac

Remote control with Raspberry Pi and Phidget WebService

Remote control with Raspberry Pi and Phidget WebService

Remote control with Raspberry Pi and Phidget WebService

In this tutorial I used the control panel Phidgets to test the operation, of course you can write your application in a language you want and with the operating system that you use normally. If you need more inputs outputs you can use the 1018 or 1012.

Remote control with Raspberry Pi and Phidget WebService

Remote control with Raspberry Pi and Phidget WebService


Be the First to Share


    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest