Using a 65 year old ammeter to monitor server load
Back to programming
My boss, Steve, likes
steampunk. He also liked the display we used to have to monitor what was going on with our servers. So, for Christmas I decided to make him an old-fashioned dial display that shows the current load on our servers. It uses the local WiFi to connect to AWS Lambda to get the current value of the relevant CloudWatch metric, in our case requests/minute to our main servers.
The load meter on Steve's desk behind his lamp. Boxing day, so not much load.
This is the meter, showing 3600 requests/minute to our main servers.
The black cable provides power. Data is over wifi.
The display is an unmodified 1mA ammeter built in 1949. I got it from
This is the wiring, showing a WEMOS D1 Mini wired to the ammeter inputs
in series with a variable resistor. The black cable is power. The gold looking zig-zag is the aerial. The mess on the top of the left peg is masking tape.
The brains is an
ESP-8266EX in the form of a WEMOS D1 Mini.
The wiring is simple, and doesn't require altering the ammeter:
The WEMOS is powered using a USB cable (black cable from the bottom).
The ground pin of the WEMOS is wired to the ground pin of the ammeter.
The D0 pin of the WEMOS is wired to a variable potentiometer which is then wired to the positive pin of the ammeter.
The code is in two parts.
Connects to the local wifi
Makes a request to a url on our servers (see below) that returns a single value between 0 and 1000
Sets PIN D0 to a voltage based on that value (this is done using the ESP-8266's ability to do
PWM) The voltage causes a current to flow through the variable resistor, which is then measured by the ammeter.
The ESP-8266 then sleeps for a minute, before repeating the process.
Amazon's API gateway, which provides an https url. When the ESP-8266 makes a GET request to that url, it is passed onto an AWS lambda function.
The Lambda function gets the latest value of a CloudWatch metric,
scales that value to be between 0 and 1000
returns that value to the API gateway, which
returns the value as the solitary content of the response body
The display is calibrated by adjusting the potentiometer.
My code is available on
github and reproduced below.
contact me if you have any questions.