Skip to content

TrainTimes is an open-source project that displays live UK train departure information for a chosen station and destination, on a dedicated device. The project fetches real-time data from the NationalRail API and is ideal for home, office, or makerspace use.

Notifications You must be signed in to change notification settings

SanjitRaman/traintimes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Train Times Departure Board

A project to display live UK train departure board information for a specific station and destination, both on a Python terminal and on an ESP32-powered OLED hardware display.

TrainTimes hardware enclosure

Features

  • Fetches live train departure data from the raildata.org.uk API.
  • Python script for terminal-based display with scrolling and blinking for delays/cancellations.
  • ESP32 firmware for displaying departures on an SH1122 256x64 OLED using PlatformIO and Arduino.
  • Customizable station and destination via config file.

Quick Start

If you just want to try it out locally on your computer, you can use the Python terminal display (see section 1 below). If you want to run it on the ESP32-powered TrainTimes device, see section 2 for the ESP32 firmware.

1. Python Terminal Display

  1. Install dependencies

    pip install -r requirements.txt
  2. Configure your API key and station
    Edit the config file to set your API key, station code, and destination CRS code:

    [DEFAULT]
    API_KEY = 'your_api_key'
    STATION_CODE = 'HDM'
    DEST_CRS = 'MYB'
  3. Run the script

    python python_model.py

This will display a live departure board in your terminal.


2. ESP32 Firmware

The main firmware is in the firmware/ directory.

Requirements

  • PlatformIO (VSCode extension recommended)
  • ESP32 Dev Board
  • SH1122 256x64 OLED display (4-wire SPI)

Setup

  1. Copy your WiFi credentials and API key into firmware/include/secrets.h:
    // secrets.h
    const char* ssid = "YOUR_WIFI_SSID";
    const char* password = "YOUR_WIFI_PASSWORD";
    const char* apiKey = "YOUR_API_KEY";
  2. Connect the OLED display to the ESP32 as per the pin mapping in DepartureBoardDisplay.cpp.

Build & Upload

From the firmware/ directory:

pio run -t upload

Or use the PlatformIO VSCode extension.


CAD

3D models for the enclosure and components are in the cad/ directory.


Contributing

Contributions to improve the project via GitHub Pull Requests are welcomed. The directory structure is as follows:

.
├── config
├── python_model.py
├── requirements.txt
├── cad/
│   └── [3D models and exports for enclosure]
└── firmware/
     ├── platformio.ini
     ├── src/
     │   └── main.cpp
     ├── lib/
     │   └── DepartureBoardDisplay/
     └── include/

License

Credits


About

TrainTimes is an open-source project that displays live UK train departure information for a chosen station and destination, on a dedicated device. The project fetches real-time data from the NationalRail API and is ideal for home, office, or makerspace use.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published