Ferrograph Display with weather and tfl (Transport for London) train data

Posted on Updated on

I got this ferrograph display as scrap about a year ago from the 3 week shelves at rLab and it gathered a lot of dust! So I started looking into testing and could see that it was functional by changing some of the headers. I then had a look on google and these displays were designed to plug into phone systems as such there wasn’t really an in.. until I saw a chap called Robert Coward had created a custom firmware.

I bought the firmware from Robert (which wasn’t cheap) but it is amazingly documented and actually brilliant.

I then hacked the input over to RS232 and plugged a Raspberry Pi into this interface.

The Pi runs a crontab every minute to download the contents of a php page which gets data about the weather and tfl.

So an evening later, I can see if the Metropolitan line is running okay and what time the 8.30 arrival is departing so I make it to the train on time.

I plan to really extend this out a lot as it is really nicely simple and very useful!

PHP code with screen output

 

date_default_timezone_set("Europe/London");

// Weather
$json_data = file_get_contents('http://api.openweathermap.org/data/2.5/weather?id=2634451&units=metric');

$json_obj = json_decode($json_data);

// Tube
$tube_status_json_data = file_get_contents('https://api.tfl.gov.uk/line/mode/tube/status');

$tube_status_json_obj = json_decode($tube_status_json_data);

// Journey - use your own key!
IsAsync=true&JpType=publictransport&InputFrom=Hillingdon+Underground+Station&From=Hillingdon+Underground+Station&FromId=1000111&PreviousFrom=&InputTo=Moorgate&To=Moorgate&ToId=1000149&PreviousTo=&TimeIs=arriving&Date=20150920&Time=0845&Mode=bus&Mode=tube&Mode=national-rail&Mode=dlr&Mode=overground&Mode=tflrail&Mode=river-bus&Mode=tram&Mode=cable-car&Mode=coach&CyclePreference=AllTheWay&WalkingSpeed=average&JourneyPreference=leasttime&AccessibilityPreference=norequirements&MaxWalkingMinutes=40&WalkingSpeed=average&InputVia=&DataSetsJson=%5B%5B%22stopPoints%22%2C%22journeyPlannerNoSubmit%3FInput%3D%7B%7Binput%7D%7D%22%5D%5D&Modes=tube%2Cdlr%2Coverground%2Ctflrail%2Cbus%2Criver-bus%2Ctram%2Ccable-car%2Cnational-rail&Via=&ViaId=&PreviousVia=&NationalSearch=false&SavePreferences=false&IsMultipleJourneySelection=False&JourneyType=&IsPastWarning=False
$tube_journey_json_data = file_get_contents('https://api.tfl.gov.uk/Journey/JourneyResults/1000111/to/1000149?nationalSearch=False&&time=0845&timeIs=Arriving&&&&&&&&&&&&&alternativeCycle=False&alternativeWalking=True&applyHtmlMarkup=False&useMultiModalCall=False&app_id=XXX&app_key=XXX');

$tube_journey_json_obj = json_decode($tube_journey_json_data);
//var_dump($tube_journey_json_obj->journeys[0]);

// Output
print "_01Z00_02A0" .
"Outside now: " . $json_obj->weather[0]->description . " " . round($json_obj->main->temp,1) . "c " . date('jS H:i') . "_0C " .
$tube_status_json_obj[6]->name . " " . $tube_status_json_obj[6]->lineStatuses[0]->statusSeverityDescription . "_0C " .
"Planner: " . $tube_journey_json_obj->journeys[0]->duration . "mins, depart " . date("H:i",strtotime($tube_journey_json_obj->journeys[0]->startDateTime)) . " arrive " . date("H:i",strtotime($tube_journey_json_obj->journeys[0]->arrivalDateTime)) .
"_04";

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s