This project is designed to fetch and display real-time subway stop information on an RGB LED Matrix. It primarily indicates the uptown and downtown train schedules for a specified station. The data is sourced from the New York City Metropolitan Transportation Authority (MTA) through @Andrew-Dickinson's nyct-gtfs python library and rendered on an RGB LED Matrix using @hzeller's rpi-rgb-led-matrix python library.
The repository consists of the following Python scripts:
-
rgb.py- This script handles the interaction with the RGB LED Matrix, including initializing the matrix and displaying text on it. -
mta.py- This script is responsible for fetching subway train data from the MTA and processing it to generate a summary of the upcoming trains at a particular subway stop. -
main.py- The main driver script that combinesrgb.pyandmta.pyto fetch subway stop information and display it on the RGB LED Matrix.
- Python 3.x
- PIL (Python Imaging Library)
- nyct-gtfs python library
- rpi-rgb-led-matrix
- An API key for accessing MTA data (can be obtained from the MTA website)
- Raspberry Pi (or similar single-board computer)
- RGB LED Matrix (32x64 is hardcoded in here, but you can adjust the settings with your specific hardware)
- Adafruit HAT (or a similar HAT for connecting the LED Matrix to Raspberry Pi. Note that if you use a different hat you'll have to adjust the hardware options in rgb.py)
-
Set up your raspberry pi (raspian lite OS is recommended by @hzeller in the rpi-rgb-led-matrix documentation) and install the rgb led matrix library:
Follow instructions on rpi-rgb-led-matrix repo for installation of the rgb led matrix library.
I would recommend running the example programs and seeing if everything works correctly. If not everything works, follow the troubleshooting in the library documentation.
-
Clone the repository to your raspberry pi:
git clone [repo_url] cd [repo_directory] -
Install the required Python dependencies:
pip install Pillow pip install nyct_gtfs -
Obtain an API key from the MTA and set it as an environment variable on your Raspberry Pi:
export MTAKey="YOUR_API_KEY" -
Connect the RGB LED Matrix to your Raspberry Pi using the Adafruit HAT (or equivalent).
-
Make sure the font path and any hardware specifications in
rgb.pyare correct. You can replace it with the path of any TrueType font on your system.
To run the program, use the following command:
python3 main.py [STATION_ID]
Replace [STATION_ID] with the station ID for which you want to display the train arrivals. You can find the station ids in the included stationCSV.csv file.
For example, to get information for Times Square-42nd Street, you would use:
python3 main.py "R16"
The program will continuously display the uptown and downtown train schedules for the specified station on the RGB LED Matrix. Press CTRL+C to stop the program.
Contributions are welcome! Please fork the repository and create a pull request with your changes.
For questions or issues, please open an issue on the GitHub repository.