Close

Web Config

A project log for Stack Light Monitor

Jenkins build monitor using an industrial stack light as output.

dkt01dkt01 08/27/2017 at 21:210 Comments

Let me be the first to say that the Arduino makes a pretty bad web server.  With only 32KB flash (<28KB available for program memory) and only 2.5KB RAM, there's not much room to store or serve anything.  Thankfully, the ENC28J60 can handle a lot of the lower-level stuff and the Ethercard library from [jcw] has some good abstractions for TCP connections.  I ended up writing the website as a single file HTML/CSS/JS page that I then minified, GZIP compressed, and converted into a program memory character array in a header file.  This enabled the whole webpage to be static and stored in program flash saving valuable ram for other tasks.  Since I had a little extra room, I used the Pure css framework to make the site pretty.  Oh, and I also made a compressed favicon.ico so everything looks a little more professional.

The webpage itself uses pure Javascript to find jobs available on a server and validate settings before sending everything to the Arduino.

The Arduino uses a RESTful API to interact with the config page.  The webpage uses a GET request to retrieve the current configuration of the Arduino, then it uses a PUT request to save new settings.  The Arduino does some internal validation before saving settings in EEPROM and sending a http response code to the web page.

The Arduino uses these configuration settings to send HTTP API requests to the Jenkins server.  It then parses the JSON returned by the server to set the light pattern.

TL;DR: The Arduino is acting as an HTTP server and HTTP client simultaneously in under 28KB flash and under 2.5K ROM

Discussions