March 1, 2017

Setting up Raspberry Pi, wifi, static IP


Set up headless RPi, Wifi with static IP.


  • Windows 10 64bit
  • Raspberry Pi 1A, 1B, 3B, Zero
  • External monitor, powered USB hub, wifi dongle, keyboard/mouse.
  • RPi OS; Raspibian Jessie Lite 

Although I will be using RPi headless, the easiest way to set up is hook up external monitor, powered USB hub, connect keyboard mouse + wifi module.  I tried different headless set up, but they all were too inconvenient, especially with RPi models with only one USB port.

Install/Setup Raspberry Pi on SD

  1. Raspberry Pi OS download:
  2. I got the easy one, Raspbian Jessie Lite,
  3. Use Win32 Disk Image to write the OS onto SD card 

Setting up RPi

  1. Insert the SD card and boot it up.
  2. Log in: ID=pi, password= raspberry  
    • Do NOT change the password yet!
  3. sudo raspi-config
  4. configure/enable desired features:
    • hostname
    • interfacing option
    • overclock
    • adavnced options: memory split - 16 is the minimum. Any lower number will set it to default value.
    • localisation (select appropriate selections for your location)
      • Change Locale: uncheck everything, and check en_US.UTF-8
      • Change Timezone: America > New_York
        • Change wi-fi Country Set... : select US
  5. sudo vi /etc/default/keyboard 
    • change to: XKBLAYOUT="us"
  6. sudo reboot
  7. After reboot, test your keyboard typing special characters, such as !@#$%^ ... etc.
  8. If it works fine, then change password, typing "passwd"
    • This step is the last, because if you use special characters in password, the keyboard works properly after localization/keyboard layout change.

Setting up wifi

$ sudo vi /etc/wpa_supplicant/wpa_supplicant.conf

and edit as follow -- change BOLD strings for your wifi:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

    ssid="## YOUR SSID ##"
    psk="## YOUR WIFI PASSWORD ##"

Static IP

$ sudo vi /etc/network/interfaces

and set up as below -- chage BOLD strings to your needs:
auto lo
iface lo inet loopback

iface eth0 inet static

allow-hotplug wlan0
iface wlan0 inet static
        wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

allow-hotplug wlan1
iface wlan1 inet manual
        wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

Don't forget to disable DHCPCD:
$ sudo systemctl disable dhcpcd

Reboot and check your static IP
$ sudo reboot

...after reboot and check...
$ ip addr

Update and Install Software

Update, upgrade:

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo reboot

Install Software:

$ sudo apt-get install mc tree screen python figlet dnsutils python-setuptools python-pip

Note: for web server, I prefer Apache for normal servers H/W, but for RPi, it's better to use Nginx as its memory usage is a lot lower.

No comments: