Getting started with Raspberry Pi 2

Posted on Sun, 22 February 2015 in development

Internet of Things has been on top of hype for quite some time. Surely every nerd out there must have a go on this :) Here’s the beginning of mine.


I chose Raspberry Pi 2 as the basis for my experiments. Quite many of my friends have already produced some amazing stuff with this tiny and affordable computer. So I am relying on the fact, that help is available when needed, on top of the always helpful internet, of course.

Initial setup and first boot

When I purchaced my Raspberry Pi, I bought also a pre-installed NOOBS SD memory card to get an easy start.

There are plenty of guides already online, here is how I did it.

  1. Slot in the SD memory card.
  2. Plug in your USB keyboard and mouse, and display via HDMI cable.
  3. Plug in the micro-USB power cable, and your Pi will boot for the first time.
  4. From the window that opens, you can select, which of the operating systems you want to install by ticking the appropriate one and clicking Install. I chose to install Rasbian, which is a Debian based Linux distro optimized for Raspberry Pi.
  5. The installation process will take a couple of minutes, grab yourself a cup of coffee.

Configuration menu

When the installation is complete, the Raspberry Pi configuration menu (raspi-config) will open. You can move around the menus with arrow keys, Tab and Enter.

Configure locale

Here you should change the locale to what you want to use by going to menu change_locale. I chose en_US UTF-8, en_GB UTF-8 and fi_FI UTF-8 by selecting them with Spacebar. Select Ok with Tab and select then the default locale on the next screen. I chose en_GB UTF-8.

You can change the locale afterwards from Linux shell by giving the command

sudo dpkg-reconfigure locales

which will bring you to the same menu.

Configure keyboard layout

Since there are numerous different keyboard layouts and physical keyboard models, you need to tell the Raspberry Pi, how to interprete the key presses. This is done in menu configure_keyboard.

Since I live in Finland and use the Scandinavian keyboard layout with 105-key keyboard, and the exact model was not listed, I chose Generic 105-key (Intl) PC, and on the next screen Other, then Finnish, and once again Finnish.

Second to last thing is to configure the AltGr modifier key, which you need to input some special characters, such as @. I chose the default Right Alt (AltGr).

The final thing is to select the behaviour of the Ctrl + Alt + Backspace key combination. Default Yes works for the most, me included.

Wait a little while for the changes to take effect.

You can change the keyboard layout afterwards from Linux shell by giving the command

sudo dpkg-reconfigure keyboard-configuration

Change the password for user pi

All Raspberry Pis have the same default password for the user pi, which you should change to add a little security. Select the menu change_pass and type the new one, twice as prompted. (note that the password is not shown in Linux shell as you type)

Configure timezone

Last thing to configure is the timezone you are in. Select menu change_timezone, and select the appropriate one. I chose Europe > Helsinki, which is UTC+2h.

That’s it, all set. Select Finish and hit Enter. After you get to the shell / command line, reboot the computer by typing the following

sudo reboot

Launching the GUI and setting WLAN

After the Pi reboots, it asks for user account to login, type pi and enter the password you chose in the configuration phase.

When you are logged in and in the shell, type startx to launch the LXDE window manager. The GUI (Graphical User Interface) launches and you have some use for your mouse once again!

I launched the GUI to set up network and for that I use USB-powered WLAN adapter. Make sure that the USB-adapter is in place (if not, insert and reboot).

  1. On the desktop select and open the program Wi-Fi Config.
  2. Click Scan to find available wireless networks.
  3. Double click on the network you wish to connect to.
  4. On the new dialog enter your network password to the field PSK. Change the Authentication if needed.
  5. Hit Add and Close on the previous window.

To test out the connectivity, open the Epiphany web browser and open some nice page like the Raspberry Pi home page and see that it opens. All set!

Feel free to explore the wonders of the LXDE. After you have had enough for this time, it’s time to do one important task, now that we have network (and thus internet) connection. To exit the LXDE to shell, select Menu > Shutdown… > Logout.

Update the operating system

When you are back at the shell, it’s time to ensure that the Pi is running on the latest updates. This is important to do regularly (say once a month), since updates fix bugs in programs and thus enhance security, and bring new functionality.

To update the system’s package list run command

sudo apt-get update

and after that run the upgrade itself

sudo apt-get upgrade

The Linux Kernel and firmware updates are installed as Debian packages also, so that too is taken care of.

Note: When running the upgrade, it will show how much data will be downloaded and how much space it will require. Make sure by running df -h that you have enough disk space free, as sadly apt will not do this for you. The downloaded package files (.deb files) are stored in /var/cache/apt/archives. You can remove these in order to free up space with the command

sudo apt-get clean

Reboot your Pi once more, with the command sudo reboot.

Shutting down the Pi

When for some odd reason you want to showdown your Pi, you should not just pull the power cord out, since this may corrupt the file system in the worst scenario. To shutdown the Pi appropriately, you shoud do so with the command

sudo shutdown -h now

That’s it. Time to start your first IoT project.