3

I got myself a Pi Zero W a few weeks back. After installing Raspbian on a sdcard and doing all the setup procedures (making the wpa_supplicant.conf file), I was able to connect it to my wifi. Then just a few days back, due to reasons, I had to re-install Raspbian on my SD card. After following the same procedures for setup for wifi connection, my Pi Zero hasn't been able to connect to my wifi. The wpa_supplicant.conf file contains this

network={  
        ssid="wifi1"  
        psk="password1"  
        key_mgmt=WPA2-PSK  
}  

network={  
        ssid="wifi2"  
        psk="password2"  
        key_mgmt=WPA2-PSK  
}  

Please, can anyone tell me a solution or if I am missing out any steps?

2
  • What is the output of sudo systemctl status dhcpcd ? And does sudo ifconfig show the WiFi interface? Nov 13 '17 at 18:00
  • If this is the total content of the file, it is missing the header. What you have listed is intended to be APPENDED to the file. I believe Stretch is more strict than Jessie.
    – Milliways
    Nov 13 '17 at 22:46
1

My problems with the pi0w were seen in systemctl status dhcpcd which stated, that there were problems starting up. So I fixed my /etc/network/interfaces to:

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
auto wlan0

iface lo inet loopback

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

and the /etc/wpa_supplicant/wpa_supplicant.conf file contains:

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

network={
        ssid="network_name
        psk="pw"
}

Since you do not want to write your password in clear text, you can issue

wpa_passphrase ssid pw

and the the resulting string for the network entry. This is a hashed password. But remember to delete the commented clear password. I hope this helps! Otherwise provide more data from your systemctl output.

0

The later versions of Raspbian/Raspberry Pi OS disable/block the WiFi by default (with rfkill) untill the country code is set using the raspi-config utility (select 5. Localisation Options-> WLAN Country). This does two things - it sets the country code (e.g. country=GB for UK) in the /etc/wpa_supplicant/wpa_supplicant.conf file and crucially it unblocks the WiFi interface using the rfkill system. The rfkill utility can be run directly to unblock the wifi:

 sudo rfkill unblock wifi

The above all applies if you can actually log into the Pi Zero - if not then if you mount the sdcard as a drive on another computer - it should appear as the boot drive. Then you can copy a suitable wpa_supplicant.conf file (see @mike's answer as an example) to the boot directory. It should then work... But if not then you may need to the edit the cmdline.txt file in the boot directory and add these two parameters on the end of the first line:

systemd.restore_state=0 rfkill.default_state=1

The first one disables the systemd rfkill restore service, whilst the second sets the default kernel rfkill status to enabled.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.