What's the time and when's my next train? (London tube edition)


I thought I’d share my first imp project - a Neopixel clock that shows when the next few trains are due at my station. It’s at the “minimum viable prototype” stage so plenty of work to do. Apps like Citymapper provide similar info already in London but I liked the idea of something physical to show it at a glance in the morning before I leave the house. Also a great excuse to get some neopixels and play around with agents. A learning project for me so it’s quite hacked together and I’ve yet to figure out if it will actually be useful or not…! The code is brought to you by copy/paste, google and trial and error so if I’ve done something silly please let me know!

Hardware: Adafruit’s 24 neopixel ring with an April board. Arduino in the picture is only there as a 5v voltage regulator for the neopixels…

Each pixel represents 2.5 minutes or half an hour. Red shows hours, blue minutes and green when a train is due:

Software: data is sourced using the Transport for London API for predicted train times. A python script runs on a server every minute and updates a file with the time and seconds to train arrivals. An imp agent fetches the file and processes the data to calculate which pixels on the ring to illuminate for hour, minute and each of the trains. The agent passes the device a table containing hour/minute pixels and an array of train pixels, which the device then uses to create the display.

It works reasonably well with a few issues:

-seems to freeze up occasionally and get stuck at a certain time. Not yet sure if this is a code or power problem.

-I can’t get the neopixels to work reliably when directly connected to the imp - for example, setting pixel 5 to 20,0,0 would turn on pixel 3 dim blue and pixel 4 bright green. Using a level shifter to 5v on the data line appears to solve this completely.

Future plans on software include having the minute pixel blink to differentiate it more than just by colour, and maybe some way to show if there’s more than one train in a given 2.5 minute window / pixel. Also how to deal with overlapping train / hour pixels. At the backend it would be nice to tidy up the python code to make it more flexible / generic to pick your tube station, line, and platform / direction. On the hardware side perhaps printing a case to make the dial easier to read at a glance and maybe using the light reading to adjust pixel brightness.

It’s been fun to work with the imp as a novice / hobbyist - the web ide and reprogramming over the air makes it much less hassle than other controllers I’ve used. Thanks to @beardedinventor et al for the helpful beginner tutorials and particularly the neopixel class.

Code link is below if anyone is interested - thanks for reading!



Nice work @vondartleroy !

Just a thought here on streamlining the setup - you could have the script which runs on the server POST the data to the agent instead of saving a file. That way it would all be done in a single process. Just a thought!

I haven’t used the 24 pixel ring yet, but I can power a 16 pixel ring on 3.3V with no problem. If you like, post your code and we can take a look at it.

Very cool looking project.

Arduino in the picture is only there as a 5v voltage regulator for the neopixels..

… that’s a pretty expensive voltage regulator :slight_smile:

Yousaf great project hope your not on the Northern Line!