Communication with the web

Encoding data

Tasks

Represent the following with Python/JSON.

Getting a web site working

No matter which web server you download, you will need to add the www-data user to the gpio and i2c groups. You should also add your own account to the www-data group.

There are a few choices for web servers. (I think) You can install more than one web server, just be sure that only one is enabled at a time.

Apache

This is the old standard. We run it at www.cs.unca.edu . Exploring BeagleBone, the BeagleBone version of the textbook, which is available on-line from the UNC Asheville library, has a section of its chapter 10, which show you how to install the Apache web server.

Here are more links to installing Apache with CGI scripts.

lighttpd

Many think the Apache is too heavy, especially for a Raspberry Pi. In the Fall 2016 CSCI 178 we used lighttpd. It worked quite well. You can follow these installation steps.

NGINX

The textbook has detailed instructions (pp 488–498) on using NGINX (engine-X) which is becoming popular. You can also follow a tutorial on NGINX and CGI to install it.

Before going on...

Regardless of the route you take, make sure your web server is working with CGI before proceeding. I suggest you try installing the shell script listi2c.cgi in your cgi-bin directory as a test.

You should also be able to connect to the I2C display on uncacsci-pi-j.cs.unca.edu.

Back to the Pi

Grab a simple I2C board with an Adafruit library, such as a 9DOF or BMP180, and install the hardware and associated Adafruit library.

Go the the examples directory for your I2C device and look for the simpletest (or simpletest.py) program.

Copy the program and modify it as follows:

After testing the program:

If all else fails

Read my history from two days ago.

Tasks for the next couple of weeks

Pi Wi-Fi

Take your favorite Pi home. Grab one of those USB WiFI adapters and try to connect your Pi to your home WiFi. I just followed the instructions in the Setting WiFi up via the command line page.

Skim through the following sections of the textbook Exploring Raspberry Pi. You can also read very similar material in Exploring Beagle which is available on-line from the UNC Asheville library.