Getting started with a Raspberry Pi
A quick start guide is available from the Rapsberry Pi Foundation, but I have tried to gather the essential information you need here. There are many other configurations possible, in particular if you do not have an HDMI TV you will need to use the video out port which can be problematic. Another alternative is to run the Pi without a screen or keyboard and connect remotely from another computer (“running headless“).
To run the raspberry pi you need:
- The raspberry pi.
- An SD card with a suitable OS on it.
- A power supply. The pi requires a micro-USB connection supplying 1amp at 5v. A modern phone charger should provide this, or you can buy battery packs or power supplies readily on the web.
- A screen that can take an HDMI input, e.g. any recent TV, and an HDMI-HDMI cable.
- A USB keyboard and mouse.
- An Ethernet cable and connection – or more useful, if you have wifi, is a mini wifi dongle.
On first booting your raspberry pi:
- On first boot choose to install ‘Raspbian’, this will take a few minutes.
- You will have to go through a config utility – make sure the camera is enabled and time zone is set correctly, otherwise default options will do.
- You will be prompted to log in: username is “pi” and password is “raspberry”.
- At this point you will have a command line prompt. The command prompt is the easiest place to install extra software or libraries. For example:
- To install the Python Imaging Library (PIL) type the following and hit return (you must have an internet connection, e.g. a live ethernet cable plugged in). Give your password (raspberry) if asked.
sudo apt-get install python-imaging
and then
sudo apt-get install python-imaging-tk - “sudo” is short for “substitute user do” and gives permission for the ensuing commands to install software.
- “apt-get install” tells the “advanced packaging tool” to get and install the software requested.
- One thing you may want to do straight away, and before installing new software thereafter, is make sure the current software is up to date. Do this by entering:
sudo apt-get update
sudo apt-get upgrade
sudo rpi-update - The first command updates apt’s list of available stuff, and the second then upgrades anything that is out of date. The third command updates the ‘firmware’, lower level code that controls how the hardware and software interact. One issue I have had with rpi-update is that it fails if the current time is wrong. Raspberry pis do not have an internal clock, so if for some reason the network time protocol fails you can set the date with the following command, then run rpi-update:
sudo date -s “Tue Mar 18 12:31:26 UTC 2014” - There are lots of other useful commands you can use, searching the web for ‘basic UNIX commands‘ or similar will reveal plenty of helpful sites. The ones I use most oftern are: ls (lists files in the current directory), cd folder_name (move into the folder folder_name), cd .. (move into the parent folder), python program.py (execute the python program program.py) and nano program.py (opens program.py in a simple text editor in the console – see nano for more). Sometimes these need to be prefixed with sudo (e.g. ‘sudo python program.py’) if the program needs extra permissions, e.g. to use GPIO pins.
- To install the Python Imaging Library (PIL) type the following and hit return (you must have an internet connection, e.g. a live ethernet cable plugged in). Give your password (raspberry) if asked.
- I work almost entirely at the command prompt, but you can launch a normal desktop environment. To move to a normal desktop environment type “startx” and press return.
- On the desktop are two IDLE icons – one for Python 2.7.3 and the other for Python 3.
- There is also a wifi config tool on the desktop. If you have a usb wifi dongle and a wifi network you can launch the desktop environment, setup wifi and then reboot (and it should automatically reconnect to wifi), or open a command line window from the desktop (LXTerminal) to install software or enter other commands.
Raspberry Pi is a trademark of the Raspberry Pi Foundation