wpa_supplicant.conf raspberry pi code example

Example 1: raspberry pi set wifi headless

crate a file in the root folder of the sd card ("boot") called 
wpa_supplicant.conf
===========contents of file:=================
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=<Insert 2 letter ISO 3166-1 country code here>

network={
 ssid="<Name of your wireless LAN>"
 psk="<Password for your wireless LAN>"
}

Example 2: wpa_supplicant.conf raspberry

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=<Insert 2 letter ISO 3166-1 country code here>

network={
    ssid="HomeNetworkSSID"
    psk="passwordHome"
    key_mgmt=WPA-PSK
}

Example 3: raspberry pi wpa_supplicant

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US

network={
     ssid="Your network name/SSID"
     psk="Your WPA/WPA2 security key"
     key_mgmt=WPA-PSK
}

Example 4: raspberry pi wifi setup wpa_supplicant

Create a file in the root of boot called: wpa_supplicant.conf (instructions below). Then paste the following into it (adjusting for your ISO 3166 alpha-2 country code, network name and network password):

country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
    ssid="NETWORK-NAME"
    psk="NETWORK-PASSWORD"
}

Example 5: raspberry wifi scan

$ sudo iwlist wlan0 scan