-Let Raspberry Pi tell you when your bus arrives

by

When the Raspberry Pi  was launched, the SIS-2012 team members were quick to order a couple of them. Each.  One of the Pi’s is now on loan for some Real Time Passenger Information (RTPI) fun, using one of the services we are developing: Get your own personal bus stop sign from Kolumbus.

If you want to join in the bus/Pi fun, pls read the detailed how-to description below! Note, however, that the actual bus stop service is not to be released until late in the autumn this year, so this crucial bit has been left out of  the description…. We’ll be putting it back in when the service is launched!

Here goes:

We have been able to acquire a Raspberry Pi Model B (the version with an Ethernet connection and two USB ports), for the going price of This is a tiny, barebone, low-cost computer running an ARM processor (the type of processors often used in smart phones).

We wanted to setup the Pi so that it boots and displays information (kiosk mode, but without keyboard and mouse) about upcoming bus departures without requiring any user intervention:

Flip switch to turn on power.
Wait…
Real-time bus departure information appears.

We are by no means experts in the Linux or Pi field, so do use the comments section below to let us know how you think it should be done. This is a description of how we did this from scratch, using our Pi and an SD card loaded with Debian “squeeze” (debian6-19-04-2012) from the Raspberry Pi download page. Check out the Embedded Linux wiki page on instructions for loading your SD card.

Parts list

  • Raspberry Pi Model B
  • SD card (Kingston 4GB SDHC Card Class 4) with Debian “squeeze”
  • USB keyboard and mouse (only needed during the setup phase)
  • Monitor with DVI input (ViewSonic VS10859 with max. resolution of 1680 x 1050)
  • HDMI male to DVI adapter
  • Mini-USB charger (by Samsung)
  • Various cables: DVI cable, monitor power cable, power extension cable and network cable.

Before first boot

Remember to always have a network cable connected during boot so that the Pi can set its time from an internet time server using the Network Time Procotol (NTP). The Pi does not keep track of time by itself when it is not powered on, so it needs an external source to tell it what time it is (like an NTP server).

Now, power up your Pi.

After first boot

Login with the user “pi” and password “raspberry” (you might want to change this later using the “passwd” command).

If you are new to Linux one way to explore the commands listed here is by trying to run “man <command>” and “<command> ––help” to figure out what the command does and what other options are available. In the listings below ‘$’ indicates that you are running in regular user mode and ‘#’ indicates superuser mode, so there is no need to type these characters.

Most of the steps listed in this section are optional. Skip to “After second boot” if your Pi is already running just the way you like it.

Enter superuser mode by typing the following command (otherwise you have to prefix almost every command with “sudo”):

$ sudo -i

Configure keyboard layout and set your timezone:

# dpkg-reconfigure keyboard-configuration
# dpkg-reconfigure tzdata

Check that the correct time is set. NTP may take a moment to correctly set the time. So wait a few moments if it has not been set correctly.

# date

If the time is not set correctly you can check your internet connection by checking if your Pi has been allocated an IP address and trying to ping a known host:

# ifconfig
# ping google.com

Run setup of the keyboard font and map used in the console. This helps startup time on the Pi where you sometimes may experience long delays during the «Setting preliminary keymap...» and «Setting up console font and keymap...» steps during boot:

# setupcon

If you run “startx” (start the X Window System) and have a big black border around the image on your screen you can try to disable overscan in the Pi config.txt file. Start your favorite text editor (vi/nano/etc.) like such:

# nano /boot/config.txt

Add the following line to the file. Then save and exit:

disable_overscan=1

Enable SSH at boot so that you can remote control your Pi using an SSH client (i.e. PuTTY for Windows users):

# update-rc.d ssh defaults

Disable startup of services we don’t usually need:

# update-rc.d -f portmap remove 
# update-rc.d -f nfs-common remove 
# update-rc.d -f xinetd remove

Fix file permission problem with NTP drift file:

# chown root:root /var/lib/ntp

Originally the Debian image is 2GB large and it does not automatically expand to take full advantage of our 4GB SD card. We can easily resize our partition manually so that it occupies the entire SD card.

Reboot and observe that all our new settings and tweaks are working:

# reboot

After second boot

Login as user “pi” and change into superuser mode, again:

$ sudo –i

Fix and update the APT (the Debian package manager) package source list:

# nano /etc/apt/sources.list

Remove the one line with “deb http://ftp.uk.debian.org/debian/ main”. Make sure that this URL only appears in the file once, preferably looking like this:

deb http://ftp.uk.debian.org/debian/ squeeze main non-free

You can also choose a different mirror site closer to your location from the Debian mirror list.

Get APT to update the list of packages:

# apt-get update

Install Chromium:

# apt-get install chromium-browser

Install unclutter, so we can hide the mouse cursor in X when the mouse is inactive, which should be all the time because our final system won’t have a mouse:

# apt-get install unclutter

Chromium configuration

To get Chromium to launch correctly in full screen mode the first time, we need to add some configuration.

# mkdir -p /root/.config/chromium
# cd /root/.config/chromium
# touch First\ Run
# nano Local\ State

In the Local State file we specify the size of the Chromium window using the bottom and right fields. Based on our resolution this is what we ended up with:

{
   "": "",
   "browser": {
      "last_known_google_url": "http://www.google.com/",
      "window_placement": {
         "bottom": 1050,
         "left": 0,
         "maximized": true,
         "right": 1680,
         "top": 0
      }
   }
}

Boot script

Create a custom boot script to automatically launch the X Window System (or just X for short).

# cd /etc/init.d/
# touch custom-x-startup.sh
# chmod +x custom-x-startup.sh
# nano custom-x-startup.sh

The boot script could look something like this:

#!/bin/sh

### BEGIN INIT INFO
# Provides:        custom-x-startup
# Required-Start:  $network $syslog $all
# Required-Stop:
# Default-Start:   2 3 4 5
# Default-Stop:
# Short-Description: Boot into X
### END INIT INFO

PATH=/sbin:/bin:/usr/sbin:/usr/bin

. /lib/lsb/init-functions

test -x /usr/bin/startx || exit 5

case "" in
    start)
        log_daemon_msg "Starting X" "custom-x-startup"
        /bin/su - root --command /usr/bin/startx
        ;;
    *)
        echo "Usage: {start}"
        exit 2
        ;;
esac

Add the custom boot script to the startup sequence like so:

# update-rc.d custom-x-startup.sh defaults

X Window System configuration

At this point X will start automatically on boot, but we also want to ensure that Chromium is launched and we want to hide the mouse cursor. To do this we have choosen to create a custom session manager, like so:

# cd /usr/bin/
# touch custom-session-manager.sh
# chmod +x custom-session-manager.sh
# nano custom-session-manager.sh

The session manager first starts unclutter to remove the mouse cursor (also from the root window, hence the -root option) and then launches Chromium in kiosk mode (hopefully) using the specified URL. The URL used in this example is to our the real-time bus stop information display service. If you would like to relaunch Chromium when it is closed you can probably do that by wrapping the last line in an infinite loop.

#!/bin/bash
unclutter -idle 1 -root &
URL="http://sis.kolumbus.no/minskjerm/FST.aspx?visMode=1&cTit=&c1=1&s1=11030898&sv1=&cn1=&template=2&cmhb=A4C636&cmhc=000000&cshb=000000&cshc=ffffff&arb=2D2D2C&rows=&period=&"
exec chromium-browser %u --start-maximized --kiosk -incognito "$URL"

Install and switch to our new session manager:

# update-alternatives --install /usr/bin/x-session-manager x-session-manager /usr/bin/custom-session-manager.sh 50
# update-alternatives --config x-session-manager

Lastly, we want to disable blanking in X so that our monitor is always kept on. We do that by creating a new X configuration file, like so (30 is probably a good number):

# nano /usr/share/X11/xorg.conf.d/30-disable-screen-blanking.conf

The file should contain the following:

Section "ServerFlags"
        Option "BlankTime" "0"
        Option "StandbyTime" "0"
        Option "SuspendTime" "0"
        Option "OffTime" "0"
EndSection

Reboot and be amazed :)

# reboot

Possible future enhancements

  • Improve boot time. Currently it takes about 1 min 30 sec. from power on until the web site has fully loaded. Maybe we might try Arch Linux to see if it is faster for our purpose?
  • Replace wired networking with wireless. We have a Netgear N150 USB adapter that we have not yet been able to get working. Inserting it before boot dramatically slows down the startup process and we have not been able to get the firmware and driver to work properly. Please give us a hint if you have tried this.
  • Buy or create our own case for the Pi to give this solution some nice packaging. Maybe a nice carrying case for the whole package with only a power cable sticking out the back. Plug in the power cable and shazam!
  • Add our company logo to the boot sequence.

Sources

EDIT: Added the full URL to our real-time bus stop information display service.

About these ads

4 kommentar to “-Let Raspberry Pi tell you when your bus arrives”

  1. ub[3]rgeek.net » Building a Status board with the RaspberryPi Says:

    [...] way less heavy than something like Gnome or KDE is still overkill for us. So instead I followed the instructions I found while trying to figure out how to disable screen blanking and created a quick-and-dirty [...]

  2. ottar Says:

    Very nice intro.

    Info to anyone getting a Rasberry Pi; I have big problems to get the keyboard to behave. It oscillate letters or does not read keys. It is well published on the net. Yes, I do have a proper USB PSU: 5V/5A that should cut it.

    This is a super application for the system. One need to go for something not too taxing on the HW. I am also thinking about an entertainment centre.

  3. Display for my Raspberry Pi | Martin's corner on the web Says:

    [...] then followed the instructions on this site to get Chromium installed and running full screen on specific site upon booting, that happens to be [...]

  4. Running Shopify’s Dashing on a Raspberry Pi | Toxaq Says:

    [...] these instructions to autostart Chrome in kiosk mode on the pi. What I did differently was to use Hexxeh’s [...]

Kommentarer er stengt.


Følg

Få nye innlegg levert til din innboks.

Bli med 44 andre følgere

%d bloggers like this: