Raspberry Pi Installation

Hermann Czedik-Eysenberg edited this page Jul 11, 2018 · 19 revisions

Download a Raspbian image (or Raspbian Lite, which doesn't include a GUI) and follow the official installation guide to copy it to an SD card.

In short (for Linux):

sudo dd bs=4M if=raspbian-jessie.img of=/dev/mmcblk0

where /dev/mmcblk0 is the SD card and raspbian-jessie.img the unzipped Raspbian image.

Then insert the SD card into the Raspberry Pi.

Upgrade

sudo apt update
sudo apt full-upgrade

Raspberry Pi Configuration

(Timezone, GPIO, Boot, Change password, ...)

sudo raspi-config

Change keyboard layout (e.g. to German)

sudo dpkg-reconfigure keyboard-configuration

Configure Wifi

Follow the instructions. In short:

Scan for networks:

sudo iwlist wlan0 scan

Add to the bottom of the file /etc/wpa_supplicant/wpa_supplicant.conf:

network={
    ssid="The_ESSID_from_earlier"
    psk="Your_wifi_password"
}

Then:

sudo ifdown wlan0
sudo ifup wlan0

To check if IP address has been assigned:

ifconfig wlan0

Automatically reconnect Wifi

To solve Wifi connection problems I installed a cronjob which automatically reconnects the Wifi if the connection gets lost:

Create the file /usr/local/bin/wifi-rebooter.sh:

#!/bin/bash

# The IP for the server you wish to ping (10.0.0.5 is my router, 8.8.8.8 is a public Google DNS server)
SERVER=10.0.0.5

# Only send one ping, sending output to /dev/null
ping -c1 ${SERVER} > /dev/null

# If the return code from ping ($?) is not 0 (meaning there was an error)
if [ "$?" != 0 ]
then
    echo "Restart the wireless interface"

    #ifdown --force wlan0
    # note: for some reason the above will not stop wpa_supplicant, therefore:
    wpa_action wlan0 stop

    ifup wlan0
fi

Make sure to replace the SERVER address with the IP address of your router or a public server (like the Google server 8.8.8.8).

Make it executable:

sudo chmod +x /usr/local/bin/wifi-rebooter.sh

Add this line to /etc/crontab:

*/5 *   * * *   root    /usr/local/bin/wifi-rebooter.sh 2>&1 | /usr/bin/logger -t wifi-rebooter

Source: Automatically Reconnecting WiFi on a RaspberryPi