Two possibilities to activate the Wifi Raspberry Pi Zero W :
1. Without screen :
1.1. Install the OS, once done, do not put the Micro SD card in the Raspberry Pi Zero W yet.
1.2. Via a File Explorer, go to your Micro SD card and create a file named wpa_supplicant.conf
containing the following code :
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US
network={
ssid=”Your network SSID”
psk=”Your WPA/WPA2 security key”
key_mgmt=WPA-PSK
}
The data entered in this file are the ones you use to connect to your home Wifi network. Depending on the security implemented in your wireless network, the key_mgmt
can be: WPA_PSK
or WPA2-PSK
(these are the two most common) or WPA-EAP
(often in business).
Save this file and close it.
1.3. Do the same to enable SSH by following this tutorial .
1.4. Insert your Micro SD card into the Raspberry Pi Zero W and start it.
If all went well, your Raspberry Pi Zero W will connect to your home Wifi network.
All you have to do is find his IP and connect to it with SSH .
2. With a screen and keyboard connected to your Raspberry Pi Zero W, proceed as follows :
2.1. Find his IP and connect to it with SSH.
2.2. Type the following command : sudo nano /etc/network/interfaces
2.3. Go to the end of this file and add the following code :
auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
To save tap ctrl+o
and ENTER, then leave the editor type ctrl+x
.
2.4. Optional : To scan all visible and available Wifi networks use the following command : sudo iwlist wlan0 scan
2.5. Type the following command : sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
.
Go to the end of this file and add the following code:
country=FR
network={
ssid="MY_Wifi_SSID"
psk="My_Password"
key_mgmt=WPA-PSK
}
Adapt the “country” parameter according to your region: FR = France, BE = Belgium etc. Or use the commandsudo raspi-config
(see below*)
To save type ctrl+o
and ENTER, then leave the editor type ctrl+x
* To adapt automatically the “country” parameter according to your region, type the command sudo raspi-config
, select “Localisation Options” press , tape ENTER, then select “Change Wi-fi Country” and select your country.
Once your country is selected, type ENTER, again ENTER, TAB twice to select Finish, and ENTER one last time.
2.6. Restart the PI with the command : sudo reboot now
.
To check if you are connected to your wifi, type the command ifconfig wlan0
, you should see something like that :