Initial Raspberry Pi Setup

From Domoticz
Jump to: navigation, search


  1. Use a Class 10 SD card
  2. Make sure you are using a Class 10 SD card. And a good one at that! This is important, cheap SD cards bought from eBay will cause you problems in future.
  3. Download the latest Raspbian Jessie Lite SD card image.
  4. Write the image to your SD card (follow these instructions if you need help) Windows,Mac OS X, Linux.
  5. Because SSH is disabled by default, place an empty file name 'SSH' on the SD-card to enable SSH on boot
  6. The Raspberry Pi should be unplugged from the 5V power.
  7. Put the SD card in your Pi and connect a mouse, keyboard, Ethernet cable and monitor. Finally plug in the micro USB power supply. This action will turn on and boot your Raspberry Pi.

First time startup

The default username and password are pi and raspberry

Getting an IP Address with Local Access

The Raspberry Pi image is configured with DHCP, meaning it will automatically fetch an IP Host Address, Gateway Address and DNS Address from your router.
If you additionally connect to your router after the Raspberry Pi is running and find its 'DHCP' section, you will be able see the IP Address assigned to the Raspberry Pi (these are sometimes called 'leases').
Otherwise connect the Raspberry Pi to a monitor and keyboard to gain local access. Incidentally, if a monitor is connected during boot up, you will see at the end of the boot messages the IP Address assigned.
Turn on the Raspberry Pi with its monitor and you should eventually see the command line interface.
Login with the default username and password (pi/raspberry) and issue the following command:


Using SSH to Access the Raspberry Pi (Highly Recommended)

Once you know the IP Address of the Raspberry Pi, you can use a SSH Client (Putty for example) to connect to the Raspberry Pi.
When you are using the SSH command line client in Linux or on Mac OS, you have to add the userid to the SSH command:

 ssh pi@<ip-address>

Change the Time Zone and Expand File System


Once you are logged in, issue the following command:

 sudo raspi-config
  • Select the option to expand the root file system
  • We highly recommend changing the password.
  • Change the timezone to match your locale. Timezone settings is under Internationalization Options
  • Optionally disable SSH (although enabling SSH means you can maintain a "headless" system by SSHing from your favourite computer, as highlighted above). The settings are under Advanced Options
  • Select Finish and choose reboot

Additional setup information

Set a Fixed IP Address

There are two different alternatives depending on the Raspbian version on the SD image. Later versions are currently called Debian Jessie (2018).

Version 3530 and earlier (Debian Weezy)

Log in locally or by SSH. Open the network configuration file:

 sudo nano /etc/network/interfaces

And change the code to your liking

iface eth0 inet static
address # << change to an ip address in your network
gateway # << change to your gateway

The interface file could look like

auto lo
iface lo inet loopback
iface eth0 inet static
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicat/wpa_supplicant.conf
iface default inet dhcp

Version 4834 and later (Debian Jessie)

Log in locally or by SSH. Open the network configuration file:

 sudo nano /etc/dhcpcd.conf

And add the following code to the beginning, adapted to your IP Addresses

interface eth0
static ip_address= # << change to a spare IP Address in your network (make sure it's outside of the DHCP range)
static routers= # << change to your gateway (usually your router)
static domain_name_servers=   # << change to your DNS (usually your router) 

After closing and saving the file, issue the following commands:

 sudo reboot

Maintaining and Updating your System

Always Keep your OS up to Date!

It is always essential to keep your system in good shape.
This can be simply done by either logging in locally or remotely by SSH and typing the following commands:

 sudo apt-get update
 sudo apt-get upgrade

Accept all prompts with a 'Y'

Shutdown Properly!

I would like to stress, that you DO NOT TURN OFF a system by unplugging the power cable!
This is especially NOT good for Unix systems running from an SD Card. This will eventually result in a broken/damaged file system causing no end of problems later on such as misbehaving operation (bugs that are not there) to a Raspberry Pi unable to boot. It might reboot OK the first time but it's like spinning a Roulette wheel - one day it won't come back. You have been warned!...

To turn off the system properly, login via SSH (or locally via Keyboard/Mouse/HDMI) and type:

 sudo poweroff