Summary
Muni Minutes is designed to allow for ambient displays of Muni train (or bus) arrival times, without constantly checking one’s phone or computer for nextmuni.com predictions. Such ambient information is useful to have presented at a bus stop, in a nearby cafe, or even in the home.
The system involves two parts, a "server" piece which fetches predictions from the nextmuni.com site and presents them in a simplified format, and the "client" piece, which displays these predictions to the users in the surrounding area.
System Diagram
-
The client asks the server for predictions at its location
-
Server asks nextmuni.com for predictions at the client’s location
-
nextmuni.com responds to the server’s request
-
server extracts the name of the stop, and the predictions, and sends them to the client
-
the client displays the information in the appropriate way (led sign, "bus siren", etc)
The display method is controlled entirely by the client.
The Server
|
Note
|
add link to source repo here. |
The server software is not terrifically complex. It is based on yourmuni, the yourmuni source is available at github. Like yourmuni, muniminutes runs on Google’s AppEngine service.
There are a few special URLs which are unique to muniminutes, they are explained below.
-
/devices - lists all available display devices.
-
/device/new - create a new device.
-
/device/${devicename}/times - simplified display of arrival times.
What’s a "Device"?
A device is the server-side term for the client-side display. Devices have a few simple properties, but most importantly, they have a name, and a nextmuni url.
-
the Name is used to identify the device to the server.
-
the nextmuni URL allows the server to know which location the device is in, and how to fetch the arrival predictions.
The Client
Also known as the display, or Device, the client periodically fetches its predictions from the configured server url, and displays them in whatever fashion it chooses. Below are details of a "Reference Implementation" of the client interface.
Sample Client Details
My first client consists of an Asus WL-520GU access point running DD-WRT. Attached to this via USB is an arduino board, attached to a SparkFun serial 16x2 LCD.
The following script runs on the Asus access point, which sets up some usbserial parameters, and then just pipes data to the arduino. (Comments stripped for brevity)
#!/bin/sh DEVICE_NAME="stoplight1" TTY="/dev/ttyUSB0" MM_SERVICE_URL="http://muniminutes.appspot.com/device/${DEVICE_NAME}/times" BAUD_RATE=9600 # MUST match the Serial.begin() call in the arduino code. exec 3> $TTY stty -F ${TTY} cs8 ${BAUD_RATE} ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts while true; do wget -q ${MM_SERVICE_URL} --output-document - >>&3 sleep 30 done
The Arduino code is a bit more tedious, but it just parses the incoming data, displays it on the screen, and lights up some LEDs to indicate how much time remains until the next train arrives.
|
Caution
|
circuit diagrams and micro controller code to come eventually. |