Skip to content

weberel/public-transport-display

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Public Transport Display

An ESP32-based departure board that displays real-time Swiss public transport connections on a 2.9" E-Paper display. Uses the Swiss Public Transport API to show upcoming departures with platform, line, and countdown information.

Display Example

Features

  • Real-time departure information from any Swiss station
  • Multiple routes displayed simultaneously (sorted by departure time)
  • Delay information displayed
  • Low power E-Paper display (retains image without power)
  • Desktop simulator for development without hardware
  • Configurable update intervals (API fetch vs display refresh)

Hardware

Component Model
Microcontroller ESP32-C3-SuperMini
Display 2.9" E-Paper (SSD1680, 296x128, B/W)

Wiring

E-Paper Pin ESP32-C3 GPIO
CLK (SCK) GPIO4
DIN (MOSI) GPIO6
CS GPIO7
DC GPIO5
RST GPIO3
BUSY GPIO2

Software Requirements

ESP32 Build

  • PlatformIO (recommended) or Arduino IDE
  • ESP32 board support

Desktop Simulator

  • GCC compiler
  • SDL2 library (sudo apt install libsdl2-dev)
  • libcurl (sudo apt install libcurl4-openssl-dev)

Setup

1. Clone the repository

git clone https://github.com/yourusername/SBB-Tafel.git
cd SBB-Tafel

2. Configure WiFi and Routes

Copy the example configuration and edit with your settings:

cp include/config.h.example include/config.h

Edit include/config.h:

// WiFi credentials
#define WIFI_SSID "YOUR_WIFI_SSID"
#define WIFI_PASS "YOUR_WIFI_PASSWORD"

// Route configuration
#define ROUTE_1_FROM    "Zürich Altstetten"
#define ROUTE_1_TO      "Zürich HB"
#define ROUTE_1_COUNT   6

#define ROUTE_2_FROM    "Zürich, Altstetten"
#define ROUTE_2_TO      "Zürich, Bäckeranlage"
#define ROUTE_2_COUNT   6

Station names must match the Swiss Public Transport API format.

3. Build and Flash (ESP32)

# Build
pio run

# Upload to ESP32
pio run --target upload

# Monitor serial output
pio device monitor

4. Desktop Simulator (Optional)

Build and run the simulator to test without hardware:

cd simulator

# Build with real API data
make

# Or build with mock data (no network required)
make mock

# Run
./sbb_sim

The simulator opens an SDL window showing the display output.

Configuration Options

Edit include/config.h to customize:

Option Default Description
NUM_ROUTES 2 Number of routes to display
MAX_CONNECTIONS 6 Connections to cache per route
DISPLAY_CONNECTIONS 5 Connections shown on display
API_FETCH_INTERVAL_MS 300000 (5 min) How often to fetch new data
DISPLAY_UPDATE_INTERVAL_MS 60000 (1 min) How often to refresh display

Project Structure

SBB-Tafel/
├── include/
│   ├── config.h.example    # Configuration template
│   ├── connection.h        # Data structures
│   └── display.h           # Display interface
├── src/
│   ├── main.cpp            # ESP32 main loop
│   ├── api_esp32.cpp       # WiFi & API (ESP32)
│   ├── display_esp32.cpp   # E-Paper driver (ESP32)
│   └── render.c            # Shared rendering logic
├── simulator/
│   ├── src/                # Simulator-specific code
│   ├── u8g2/               # U8g2 graphics library
│   └── Makefile            # Simulator build
└── platformio.ini          # PlatformIO configuration

How It Works

  1. Startup: Connects to WiFi, initializes E-Paper display
  2. API Fetch (every 5 min): Fetches departure data from transport.opendata.ch
  3. Display Refresh (every 1 min): Recalculates countdown times from cached timestamps
  4. Rendering: Merges all routes, sorts by departure time, displays top 5

The split between API fetch and display refresh reduces API calls while keeping the countdown accurate.

API

Uses the free Swiss Public Transport API:

GET https://transport.opendata.ch/v1/connections?from=X&to=Y&limit=6

No API key required.

Dependencies

ESP32 (via PlatformIO)

Simulator

  • U8g2 - Graphics library
  • cJSON - JSON parsing
  • SDL2 - Display output
  • libcurl - HTTP requests

License

MIT License - see LICENSE file.

Acknowledgments

About

Code to display public transport connections on a small display featuring an esp32 and a 2.9" epaper display.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors