Brendan Nee

Building a real-time transit information kiosk with Raspberry Pi

January 11th, 2013

I’ve been playing with raspberry pi a lot lately and managed to make a real-time transit display for my kitchen. This shows the real-time arrival predictions for the transit routes near me, a map of the stops, the weather, and recent tweets from my roommates.

transit-display

It was surprisingly easy to set up, so I’ll post the steps:

1. Get a raspberry pi

Raspberry pi’s are really popular, so it has been tricky to find a distrubutor with them in stock. I was able to purchase one in the US from MCM Electronics for $35.

2. Get some parts

You’ll need a few other parts, but you may already have some of these laying around:

You’ll also need the following for setup purposes:

  • A computer
  • SD Card Reader – $6.14 – (your computer may have one built in)
  • USB Keyboard
  • USB Mouse

3. Get Raspbian

Download and install Raspbian (the Raspberry pi OS) to the SD Card. If you want to skip this step, you can buy SD cards with Raspbian pre-installed.

4. Set up the pi

IMG_20130110_150050
Once you have raspbian installed, put the SD card in your pi, connect the power microUSB to power, connect the keyboard and mouse and connect the HDMI cable to the DVI port on your monitor. You’ll also want to connect it to the internet via eithernet for this initial setup. The Raspberry pi will power on automatically and if you are lucky you’ll see the raspi-config setup screen.

You’ll want to do the following setup:

  • “expand-rootfs” – Expand root partition to fill SD card
  • “change_pass” – Change password for ‘pi’ user
  • “change_locale” – Change the locale to your area (default is Great Britain)
  • “change_timezone” – Set your timezone
  • “boot_behaviour” – Set to boot to Desktop on boot
  • “update” – update raspi-config

After this, select “Finish” and then reboot the pi:

$ sudo reboot

5. Make the pi a kiosk

Thanks to Nicolò Paternoster’s instructions on pikiosk.tumblr.com

When you restart your pi you’ll be asked the log in. The default username is “pi” and the default password is “raspberry” – although you may have changed that in the above step.

First we want to update the pi and install chromium (our browser) and x11-server-utils and unclutter to make the cursor disappear. This will take a while.

$ sudo apt-get update
$ sudo apt-get upgrade -y
$ sudo apt-get install chromium x11-xserver-utils unclutter xvkbd -y
$ sudo hostname transit

Next, we want to update the pi so that it doesn’t show the screensaver and it automatically loads chromium in kiosk mode with our transit display on startup. Edit ‘/etc/xdg/lxsession/LXDE/autostart’:

$ sudo pico /etc/xdg/lxsession/LXDE/autostart

Comment out the line with ‘@xscreensaver -no-splash’ using a #

#@xscreensaver -no-splash

Add the following lines, but replace the URL in the last one with the URL that you’d like to display.

@xset s off 
@xset -dpms 
@xset s noblank
@chromium --kiosk --incognito bart.blinktag.com/?station=16TH

If you are connecting it to a monitor via DVI, you may want to force the pi to use its HDMI output (and not default to RAC). Edit ‘/boot/config.txt’:

hdmi_force_hotplug=1

Now, we’ll setup the wireless. We installed xvkbd, a virtual keyboard, so you can unplug the USB keyboard and plugin the USB wireless card.

  • Open the virtual keyboard xvkbd
  • Click on the Wifi Setup icon on the desktop
  • Click “Scan”, select your wireless network
  • Using the virtual onscreen keyboard, type in the wireless password

Restart the pi, and you are done.

$ sudo reboot

6. Access the display remotely

From the same network, you can SSH to the pi. First you have to figure out what its IP address is. You can do this using nmap or by logging into your router and showing all clients on your network.

# determine your computers local IP address
ifconfig

# scan all devices on your network (if your computer's IP is 192.168.1.49, for example)
sudo nmap -sP 192.168.1.*

# the raspbery pi may show up as manufacturer "unknown" if you are using wireless.  
# Try sshing to each device you think may be the pi
ssh pi@192.168.1.144

Once you’ve successfully connected, you may want to reboot:

$ sudo reboot

You may want to restart chromium at some point:

# stop chromium
sudo killall chromium

# manually set the display to one that is currently being used
# start chromium in kiosk mode with the URL we want to load 
# use nohup so it stays up after we disconnect
DISPLAY=:0 nohup chromium --kiosk --incognito bart.blinktag.com/?station=16TH &

7. Customize the display

All of the pi-specific stuff is done, but you need to choose what actually gets displayed. You can use my BART realtime display kiosk page or grab the source. You can link directly to a specific station’s page using ‘?station=16TH’ after the url.

I also created a more detailed realtime display combining MUNI and BART for the Mission – feel free to modify it as needed to make it specific to your location. Alternatively, you could simply point to nextbus directly.

8. Extend this

There is a lot more you could do, including using 3G instead of wifi, allowing user input, using motion detection to do something when someone walks by or even print a timetable/map using a receipt printer.