A small Raspberry Pi project I built to answer one very important daily question without wasting precious time:
“Do I need to sprint for the bus, or can I stay inside a bit longer?”
Instead of risking missing the bus by wasiting time looking up when the next one was coming, I built a physical button by my front door . When pressed, it would query OC Transpo’s API and beep the number of minutes until the next #2 bus arrived .
- Few beeps → panic, grab shoes, run
- Many beeps → relax, wait inside in the warm
Simple, fast, and perfectly effective.
- A button mounted near the door is pressed
- The Raspberry Pi calls OC Transpo’s public API
- It retrieves the next arrival time for a specific stop and route
- The system:
- Beeps once per minute until arrival
- Blinks an LED the same number of times
- Raspberry Pi
- Button
- LED
- Buzzer
- Pretty pink cardboard box to put it all in
All components were wired directly to the Pi’s GPIO pins and housed in a compact box.
📸 Photos of the hardware setup and enclosure can be found in the repo (and may be added to this README later).
The project is written in Python and uses:
gpiozerofor GPIO handlingrequestsfor HTTP calls- OC Transpo’s API to fetch real-time bus data
- Press button → block until input
- Call OC Transpo’s
GetNextTripsForStopendpoint - Extract the next trip’s
AdjustedScheduleTime - Beep & blink once per minute
If the API call fails, the buzzer emits a long error beep.
This project uses the OC Transpo REST API:
Endpoint used:
GetNextTripsForStop
Inputs:
- App ID
- API Key
- Stop number
- Route number
Output used:
AdjustedScheduleTime(minutes until arrival)
You’ll need to request your own API credentials from OC Transpo and store them in an env.py file:
appID = "YOUR_APP_ID" apiKey = "YOUR_API_KEY"
- Install dependencies:
pip install requests gpiozero
- Wire up the button, LED, and buzzer to GPIO pins
- Add your API credentials to
env.py - Run:
python bus_button.py
Press the button and listen carefully 👂