Skip to content
This repository was archived by the owner on Jan 2, 2026. It is now read-only.

MMarsland/BusButton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚌 Bus Button (OC Transpo)

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.


✨ How It Works

  1. A button mounted near the door is pressed
  2. The Raspberry Pi calls OC Transpo’s public API
  3. It retrieves the next arrival time for a specific stop and route
  4. The system:
    • Beeps once per minute until arrival
    • Blinks an LED the same number of times

🔧 Hardware Used

  • 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).


🧠 Software Overview

The project is written in Python and uses:

  • gpiozero for GPIO handling
  • requests for HTTP calls
  • OC Transpo’s API to fetch real-time bus data

Core Logic

  • Press button → block until input
  • Call OC Transpo’s GetNextTripsForStop endpoint
  • Extract the next trip’s AdjustedScheduleTime
  • Beep & blink once per minute

If the API call fails, the buzzer emits a long error beep.


📡 OC Transpo API

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"

▶️ Running the Project

  1. Install dependencies:
pip install requests gpiozero
  1. Wire up the button, LED, and buzzer to GPIO pins
  2. Add your API credentials to env.py
  3. Run:
python bus_button.py

Press the button and listen carefully 👂

About

A Simple Raspberry Pi Project to allow me to determine how soon the next bus is coming without needing to waste precious seconds looking it up on my phone.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages