Wednesday, November 1, 2023

I built a Bus Clock with a Raspberry Pi #RaspberryPi #Python @Raspberry_Pi

Purple Hoisin had a problem: missing public transportation by mere second, then having to wait for the next arrival. Rather than use a transport app, they created a bus clock to always see when to hurry up and get out to catch the bus.

Since I already had an unopened Raspberry Pi 3B that I ordered in 2016 (6 years ago!!) I decided it was now the perfect opportunity to start using it. I also needed a screen to display the times but I was a bit hesitant to buy it before the project even started, considering I bought the Raspberry Pi and never even touched it. But just like many times before, I told myself this time it would be different and I would take this project over the finish line so I went ahead and ordered a 4-inch, plug-and-play (mostly) HDMI display.

Fortunately, the Raspberry Pi runs a full Unix system and you can program it with whatever you want, unlike other simpler chips out there. On top of that, I didn’t have the patience to read a data sheet, program I/O pins or learn a chip-specific language – so I went with Python.

Once the Python environment was up and running, I had to somehow fetch the live bus data from TFL (Transport for London) and for that I decided to just scrape the local transport website using the good old requests package and BeautifulSoup4. The full code is available at github.com/purplehoisincoder/…/bus_time.py

See more about this build in the post here.

No comments:

Post a Comment