Hey folks,
I'm new to the forum and thought I'd share a sketch I've been working on. It's in beta but largely functional - any feedback, comments or suggestions are welcome.
The Tegan Web Server (TeganWS) is an Arduino web server (developed on Intel Edison) that provides the following features:
- Pre-built web pages for setting and displaying analog and digital pins.
- Ability to serve standard HTML files by supporting HTTP GET requests from browsers.
- HTML Page Methods and Substitution Tags enabling web pages to include server-generated data in standard HTML files. (See below)
- Built-in logging capability for both HTTP requests and system errors/warnings.
- HTML file upload capability for easy updating of server web pages from a client.
- Debug setting for dislaying all HTTP incoming and outgoing packets.
- Favicon support
The Tegan Web Server runs in the Arduino environment, was written on Intel Edison and is configured for WiFi but should be easily portable to both standard Arduino and Galileo boards and is currently in V1.0. (I will be testing it on an Arduino + Enet shield shortly). TeganWS is useful for:
- Displaying and controlling the I/O (digital, analog, PWM) of your Edison/Arduino.
- Providing a custom web interface to your Arduino application.
- Running a simple web server serving simple HTML web pages from an SD card.
- Integrating Arduino-generated data into standard HTML web pages.
Page Methods and Substitute Tags
One challenge with a basic web server that simply streams back static HTML pages is the inability to report back dynamic data such as the reading of an A/D pin. Even if the A/D reading could be reported back it is often useless since most of the time it's an input to a computation, such as calculating the temperature from a thermistor reading. To generate a result page with useful data many Arduino web servers hard-code the page in software, making for simplistic and inflexible pages.
TeganWS has two features that enable server-generated data to be displayed as part of YOUR STANDARD HTML page: Page Methods and Substitution Tags. Page Methods allow the linking of a method (aka procedure/function) to a specific HTML page so that whenever the HTML page is requested by a client the specific code on the Arduino is executed. So for example, a web page that presents the temperature might be linked to a method that reads a thermistor device on the analog input pin and calculates the temperature from that reading. However that reading still needs to be inserted into an existing HTML web page, which leads us to Substitution Tags.
Substitution Tags are a special type of HTML tag that are used in standard, user-created HTML files to insert dynamic data into the static web page. This works because the TeganWS file streamer scans the web page for these Tags as it's streaming the web page back to the client. When it finds one it substitutes the supplied data in place of the tag.
There are two types of Substitution Tags:
- PIN TAGS: A PIN Substitute Tag replaces the tag with the reading from an Analog (0-1023) or Digital (0/1) input pin. For example the Substitute Tag "<%SPAIP02>" in an HTML file would be replaced by the value of Analog Pin #2, a number between 0 - 1023.
- LIST TAGS: A LIST Substitute Tag replaces the tag with one of a list of null terminated ASCII strings generated by a Page Method.This is useful for inserting customized data into the HTML file as in the above room temperature example where the number being substituted was not a simple pin reading but the result of a temperature calculation. For example the Substitute Tag "<%SL03>" would be replaced by the 4th null-terminated ASCII string passed to the file streamer from the Page Method callee.
So the following HTML snippet added to your web page:
HOME TEMPERATURE
The temperature in the living room is: <%SL0> Celsius
would result in:
HOME TEMPERATURE
The temperature in the living room is: 23 Celsius
Analog Readings and I/O Control
TeganWS provides an I/O Control page which displays the Analog Input readings and has radio buttons for configuring, reading and writing all the digital I/O pins for easy configuration and breadboarding directly from a browser. Uninitialized pins are color-coded for easy identification.
See the attached TWS-IO.JPG for a screenshot.
Log Files
Two log files - "httplog.txt" and "httperror.txt" are kept automatically on the SD card file system. These are single line entries that are time-stamped so the operator can corrolate any errors with HTTP requests. The "syslogfile.html" HTML web page is not a file on the SD Card but rather is generated in the TeganWS code and displays the tail of each log file. Both files are limited to a size of 2 MB each before they are deleted and started again. An example of the "httplog.txt" would be:
@737 min; GET /iocontrol.html?DO13=LOW HTTP/1.1
@737 min; GET / HTTP/1.1
@738 min; GET /about.html HTTP/1.1
What TeganWS is not useful for:
- Hosting a high-volume web site.
- Advanced web site services (e.g. SSL, CSS, Java)
- Real-time applications

