Raspberry Pi Bus Schedule

Adam Derewecki
3 min readDec 31, 2018

--

Shows approaching times for the 10 and 48, first and second buses

To help myself get ready to catch a bus in the morning, I built a Raspberry Pi bus schedule to keep by the front door.

Overview

There are a few main things going on here:

  • Raspberry Pi with LCD screen in a case, running Raspbian Stretch
  • Ruby web server cloned from Github and running upon boot
  • Customization to launch fullscreen Chromium upon boot

The Ruby web server is very customized to my bus routes (and style). If you’re in San Francisco, you can crack open: https://github.com/derwiki/muni/blob/master/server.rb#L5

and update the bus lines and stops to be more convenient for you. If you’re in another city you’ll have to find an API to give predictions and wire that up yourself. The Ruby server is optional; if your kiosk website is already built and online, you can load it in the Chromium launch script.

Parts

Instructions

  1. Download Raspbian (torrent is usually fastest)
  2. Download Etcher (OS X)
  3. Write the image to the card
  4. Create /Volumes/boot/wpa_supplicant.conf:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
network={
ssid="YOUR_NETWORK_NAME"
psk="YOUR_PASSWORD"
key_mgmt=WPA-PSK
}

5. Enable ssh access by creating a file:

$ touch /Volumes/boot/ssh

6. Unmount the SD card and load it into the Raspberry Pi, connected via ribbon cable to the LCD screen. It should boot to a desktop. If you configured wifi correctly, you will be connected. You can tap the wifi button and after thirty seconds, a tooltip will appear with the RPi’s IP address:

7. Set up RemotePi to control the Raspberry Pi’s keyboard and mouse from a smartphone (optional).

I don’t have a USB keyboard/mouse, so this was the easiest solution.

$ sudo wget https://remotepi.io/drivers/remotepi_1.0.15_armhf.deb
$ sudo dpkg -i remotepi_1.0.15_armhf.deb
$ sudo /etc/init.d/remotepi start

8. Open Terminal and set up the web server:

$ mkdir ~/src && cd ~/src/# grab the basic Muni predictions Ruby repo:
$ git clone https://github.com/derwiki/muni.git && cd muni
$ sudo apt install ruby ruby-dev libxslt-dev libxml2-dev$ sudo gem install bundler$ bundle$ ruby server.rb== Sinatra (v2.0.5) has taken the stage on 4567 for development with backup from Thin
Thin web server (v1.7.2 codename Bachmanity)
Maximum connections set to 1024
Listening on localhost:4567, CTRL+C to stop

9. Create kiosk launcher script at /home/pi/Desktop/muni.sh:

#!/bin/bashchromium-browser --incognito --kiosk  http://localhost:4567

And make it executable:

$ chmod +x /home/pi/Desktop/muni.sh

10. Launch from the touch screen to verify that everything works:

11. Close the terminal running the web server.

12. Append the following command to /etc/rc.local for launching the web server upon startup:

/usr/bin/ruby /home/pi/src/muni/server.rb

13. Create /home/pi/.config/autostart/kiosk.desktop:

[Desktop Entry]
Type=Application
Name=Kiosk
Exec=/home/pi/Desktop/muni.sh
X-GNOME-Autostart-enabled=true

13. To rotate the screen 180 degrees, append to /boot/config.txt:

lcd_rotate=2

14. Disable the energy saving display power off by installing xscreensaver :

$ sudo apt update && sudo apt install xscreensaver

15. Change default password to prevent alert and secure device:

$ passwd
Changing password for pi.
Old Password:
New Password:
Retype New Password:

16. Install Comic Sans MS:

$ sudo apt install ttf-mscorefonts-installer

Restart the Pi/LCD and it should launch the bus display automatically upon boot:

From power-on to fully working kiosk display

--

--

Adam Derewecki
Adam Derewecki

Written by Adam Derewecki

Hi! I’m Adam. I live in San Francisco, write code, take pictures, and practice yoga.

No responses yet