Raspberry pi

chinasaur edited this page Nov 18, 2012 · 10 revisions

The following instructions apply to creating a kiosk using the Raspberry pi model B. The Raspberry pi is a is a credit-card sized ARM computer that retails for $35.

Simple Setup with Desktop

One of Raspberry Pi's default configurations is an interactive desktop environment from which you can launch a browser and load the transit screen manually.

Download

Download and install a raspberry pi distribution. The Raspbian “wheezy” distribution works.

Install

Follow the directions on the Raspberry Pi wiki to install.

Configure

  • Plug in the Pi to boot. You will see a BIOS manager. Edit to load the desktop on Start up. The other default settings should be fine (if you need to go back and change them at some point just run in terminal).
  • Disable Screen Saver

Run

Running without a Desktop

To save memory, speed boot time, and hopefully improve stability, you can run Midori (or another browser) on its own without a Desktop manager. Getting this setup will also make it simpler to have the Raspberry Pi boot directly into the TransitScreen as a next step.

Setup

Follow the directions above for downloading and installing the Raspbian OS. (For an even simpler, lighter setup, you could use Arch Linux, but setup/configuration is more advanced.)

During the configuration step on first boot, do not choose to start the desktop on startup. We will run a browser without a desktop manager instead. With this configuration Raspberry Pi will boot to a text login prompt and then dump you at the terminal after login.

Running the Browser without a Desktop

The simplest way to start a browser (e.g. Midori, Firefox, Chromium) from the command line without a desktop manager is with for example: xinit /usr/bin/midori -e Fullscreen -a http://dev.mobilitylab.org/TransitScreen/screen/index/11

The problem with this is that the Midori window may not be fullscreen even though Midori is running in "fullscreen" mode, because Midori doesn't behave very well without a window manager running. Other browsers handle this a little better; NetSurf is better behaved (but has no JavaScript); Firefox allows specifying the window width and height as command line options; Chromium has a specific -kiosk mode. (But Firefox and Chromium are heavier than Midori).

A good fix for Midori is to install a very lightweight fullscreen-only kiosk-specialized window manager, e.g. matchbox. Install it with: sudo apt-get install matchbox

Then create a script for xinit to run (I called mine "transitscreen"). In this file put, for example:

#!/bin/sh
matchbox-window-manager &
midori -e Fullscreen -a http://dev.mobilitylab.org/TransitScreen/screen/index/11

Now run xinit ./transitscreen (or whatever you called the script) and the Midori window should be fullscreen. (Note, due to the quirks of xinit, you have the have a forward slash in the argument for it to be handled correctly, so don't say just xinit transitscreen for example.)

Preventing screen blanking

You don't want the screen to go blank because of inactivity, so disable the X screen saver. (I haven't actually confirmed this is an issue, but based on others' reports it sounds like it's needed.) First do: sudo apt-get install x11-xserver-utils

Then add these lines to the top of your script, above matchbox-window-manager &:

xset -dpms
xset s off

Looping

Another trick is that you can have the browser open in a loop, so that it will restart itself if something crashes it. Change the midori line in the script to:

while true; do
midori -e Fullscreen -a http://dev.mobilitylab.org/TransitScreen/screen/index/11
done

Hiding the mouse cursor

If you have a mouse cursor permanently over the TransitScreen you can hide it on inactivity using unclutter. sudo apt-get install unclutter and then add unclutter & above the window manager line in your xinit script.

Protecting a kiosk

There are further measures for protecting the kiosk from tampering. For examples, see here: https://wiki.archlinux.org/index.php/Creating_a_Web_Kiosk

Booting directly to Kiosk

Once you have things configured to run correctly from the terminal, you can set everything up so the Raspberry Pi boots directly into Midori.

Autologin

See here for instructions to have Pi autologin to terminal instead of prompting for login.

Autorun on login

There are several approaches to autorunning programs on startup. The simplest is just to put the desired commands (e.g. xinit etc.) into the .profile script of the autologin user (probably the user 'pi'). Slightly nicer is to add a script to /etc/profile.d/. More details to follow.

Further fine-tuning

Screen Resolution

You may improve performance by reducing the screen resolution of the Pi; this can be forced regardless of the display plugged into the Pi by editing the config.txt file; more details to follow.

RaspberryPi Screen Blanking

In addition to the X screen saver, the Raspberry Pi seems to put itself in a blank screen mode if there is no input for a while, even if you're just at the terminal. Haven't yet confirmed that this is an issue for TransitScreen or found the way to turn it off. Probably is done in config.txt.