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.
- 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.
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.
-
Install dependencies
pip install -r requirements.txt
-
Configure your API key and station
Edit theconfigfile to set your API key, station code, and destination CRS code:[DEFAULT] API_KEY = 'your_api_key' STATION_CODE = 'HDM' DEST_CRS = 'MYB'
-
Run the script
python python_model.py
This will display a live departure board in your terminal.
The main firmware is in the firmware/ directory.
- PlatformIO (VSCode extension recommended)
- ESP32 Dev Board
- SH1122 256x64 OLED display (4-wire SPI)
- 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";
- Connect the OLED display to the ESP32 as per the pin mapping in
DepartureBoardDisplay.cpp.
From the firmware/ directory:
pio run -t uploadOr use the PlatformIO VSCode extension.
3D models for the enclosure and components are in the cad/ directory.
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/
- Uses raildata.org.uk for live train data.
- Uses ArduinoJson and U8g2 libraries for ESP32 firmware.
