How to enable Raspberry Pi (Raspbian) WiFi connection on boot

Open the boot partition on the Rasbian SD card and create a file wpa_supplicant.conf there, with the following content:

country=de
update_config=1
ctrl_interface=/var/run/wpa_supplicant

network={   
   scan_ssid=1
   ssid="MyWifi"  
   psk="abc123abc"
}

Always set the country code at the top ! If you don’t set it correctly, it won’t work!

Set ssid to the name of the wireless network.

Set psk to the wifi password.