Setting up Wi-Fi on Raspberry Pi

You can setup Wi-Fi on GUI, or you can configure it from your console. Here is how to do it from the console.

Brief steps:
1. Registering Wi-Fi Network
2. Enabling Automatic Connection
3. Connecting to Wi-Fi network

Let’s get started.

 

1. Registering Wi-Fi Network
1-1. Open /etc/wpa_supplicant/wpa_supplicant.conf

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

1-2. Add last four lines below at the end of the file. Replace <SSID> and <PASSWORD> to appropriate strings for your Wi-Fi network.

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US
 
network={
    ssid="<SSID>"
    psk="<PASSWORD>"
    key_mgmt=WPA-PSK
}

 

2. Enabling Automatic Connection
2-1. Open “/etc/network/interfaces”.

sudo nano /etc/network/interfaces

2-2. add “auto wlan0” line like below:

auto lo
 
iface lo inet loopback
iface eth0 inet dhcp
 
auto wlan0
allow-hotplug wlan0
...

 

3. Connecting to Wi-Fi Network
3-1. Disable Wi-Fi interface

sudo ifdown wlan0

3-2. Enable Wi-Fi interface

sudo ifup wlan0

* Alternatively, you can reboot the system Instead of step 3-1 and 3-2, to establish Wi-Fi connection.

sudo reboot

3-3. Check assigned IP address

ifconfig wlan0

if everything is ok, you can see a line like below:

inet addr:192.168.51.102 Bcast:129.168.51.255 Mask:255.255.254.0

Changing Keyboard Layout on Raspberry Pi

 

By default, the keyboard layout is set for UK on Raspbian OS. So, if your keyboard is not UK layout, you may want to change it. Here is the steps.

1. Launch Terminal if you are on  graphical desktop mode.

2. Open “/etc/default/keyboard” with nano (or any other editor you prefer).

sudo nano /etc/default/keyboard

The file should be like this:

# KEYBOARD CONFIGURATION FILE

# Consult the keyboard(5) manual page.

XKBMODEL="pc105"
XKBLAYOUT="gb"
XKBVARIANT=""
XKBOPTIONS=""

BACKSPACE="guess"

3. Edit XKBLAYOUT line. In case your keyboard is US layout, changed to “us”.

XKBLAYOUT="us"

4. Reboot the board.

sudo reboot

 

Setting & Booting up Raspberry Pi

This post shows steps to setup and boot up Raspberry Pi board with Raspbian, the recommended OS [1]  .

Here is the list of contents of this post.

Contents
– Prerequisites
– Steps
1. OS Image Preparation
2. Booting up Raspberry Pi board
– What’s next?
– Reference

 

Prerequisites (parentheses indicate my environment)

 

Steps
1. OS Image Preparation
Raspberry Pi loads the OS image from micro SD card, so let’s prepare the micro SC card.

1-1. Download a zip file of the latest Raspbian OS images from the official site to your PC.

1-2. Download Etcher and install it on your PC.

1-3. Insert micro SD card into PC and launch Etcher.

1-4. Select the zip file. Etcher should automatically select the drive if it detects the SD card.

1-5. Click on “Flash!” button and wait.

1-6. After complete the write process, safely eject the micro SD card. Your micro SD card is now ready.

 

2. Booting up Raspberry Pi board
2-1. Connect keyboard, mouse and display to Raspberry Pi.

2-2. Insert the micro SD card.

2-3. Connect the power supply cable and turn it on.

If everything goes well, Raspberry Pi board boots up.

 

What’s next? 
Now Raspberry Pi is up, from here is totally up to you, but before starting your project, here are some suggestions.

– Keyboard layout change
The keyboard layout is set for UK by default. So, you may want to change it first.

Wi-Fi setup
Raspberry Pi3 has on-board wi-fi chip and it makes it easy to connect to the Internet and/or your private network.

Enable SSH
By enabling SSH, you can access Raspberry Pi’s console from your remote PC.

Free up SD card space
SD card storage is relatively small and you may run out of the free space as your project goes on. Here are some tips to free up your SD card space.

Update software
Whatever you gonna do with Raspberry Pi board, it’s better to have the latest software. Enter command below and get the package list and software updated. For detail, please see the official documentation.

sudo apt-get update && sudo apt-get upgrade -y

– Disable Screen Sleep
By default the screen goes to sleep after some minutes (10 minutes?) of inactivity. It can be disabled by editing configuration file.

 

References
[1] Raspbian – Raspberry Pi Documentation
[2] Raspbian Download Page