Introduction: Full Python Web Interface Kit for PhidgetSBC3

The PhidgetSBC3 board is a full functional Single Board Computer, running Debain Linux. It is similar to the raspberry Pi, but has 8 analog sensor inputs and 8 digital inputs and 8 digital outputs. It ships with a webserver and web application to configure the SBC, but the default application cannot read analog sensors or digital inputs and can not set digital outputs.

This Instructable will guide you on how to make your web configuration a full functional interface kit on the SBCor in other words, after following this, you will be able to read sensor values, digital input/output states and set digital output states.

Step 1: Things You Will Need

The Phidgets SBC 3 board
Access to the internet
Some testing hardware like relays and analog sensors. I use the 3959 AC Solid State Relay (280Volt, 25 amp) and the 1135 Precision Voltage Sensor

Step 2: Prior Knowledge

Make sure you went trough the SBC3 user guide at http://www.phidgets.com/docs/1073_User_Guide
A good understanding of Linux an the Python Language will also assist you to understand why you do certain things, but I hope this tutorial will enable people without any programing experience or linux experience to still create a web base GUI to control the Phidgets SBC3.

Important linux Knowledge:

Make sure you can SSH into the SBC

The following article assisted me allot, and some of the code is used in my project

http://www.phidgets.com/docs/Web_Page_on_the_SBC

Step 3: Pre Pairing the PhidgetSBC3

Go into the web site of the SBC

In System, Packages, make sure you selected the complete Debain repository

Under Network, Settings, make sure you enabled the SSH server.

Under Phidgets, Webservice, make sure the webservice (This is not the web server on port 80) is running. This webservice is the communication system that is used by the SBC. My example use no password and port 5001

SSH into the SBC with putty on windows or remoter (iPad) (By default you are the root user, use the password you have used to log in to the SBC3 web page). SSH is covered on page 21 of the SBC3 user guide (1073 user guide)


Run

apt-get update

and

apt-get upgrade

to make sure your system is up to date (using the web interface to do this is possible, but sometimes failing)

Install unzip and wget by running

apt-get install wget

apt-get install unzip

Step 4: Installing Python and Phidgets Python

Read trough the Python programing guide http://www.phidgets.com/docs/Language_-_Python. You may skip the windows and mac section, but read the linux sesion

SSH into the SBC and run

apt-get install python

This will install python2.7 (currently the default) from the Debain repository. Do not use Python 3. Python 3 has some problems with the Phidgets libraries. Python 1 will probably work.

download the PhidgetsPython with wget. SSH into the SBC and run

wget http://www.phidgets.com/downloads/libraries/PhidgetsPython_2.1.8.20150109.zip

or

wget http://www.phidgets.com/downloads/libraries/PhidgetsPython.zip

The downloaded file (currently PhidgetsPython_2.1.8.20150109.zip) will be in the root directory by default (otherwise use cd command to navigate to the file)

run

unzip PhidgetsPython_2.1.8.20150109.zip

(or use whatever version that was downloaded)

Navigate to your PhidgetsPython directory (created by the previous unzip command)

cd /root/PhidgetsPython

and run

python setup.py install

This will install the PhidgetsPython library.


Step 5: Creating the Python Scripts

Nvigate to your cgi-bin of the webserver (cd /var/www/cgi-bin)

cd /var/www/cgi-bin

Download the file labeled ifk.zip (named FRK5B8XI6QD0F26.zip) into your cgi-bin using wget or any other method. Rename the file to ifk.zip using the Linux mv command

wget https://www.instructables.com/files/orig/FRK/5B8X/I6QD0F26/FRK5B8XI6QD0F26.zip
mv FRK5B8XI6QD0F26.zip ifk.zip

unzip it using unzip.

unzip ifk.zip

The directory /var/www/cgi-bin/ifk will now be created.

Now, make sure all the files in your /var/www/cgi-bin/ifk is executable by running

chmod 777 -R /var/www/cgi-bin/ifk/

Attachments

Step 6: Testing

Use your PC, mac, android, iOS browser and run http://(SBC domain or ip)/cgi-bin/ifk/WebInterfaceKit.py and play around.