16

I am trying to start up my Raspberry Pi Zero W completely headless, but somehow it won't connect to my WiFi. Here's what I did:

  1. Plug SD card running RASPBIAN JESSIE WITH PIXEL (should it be something else?) into my Windows PC
  2. Create an ssh file on the root of the SD card
  3. Create a wpa_supplicant.conf file with the following content:

wpa_supplicant.conf:

network={
    ssid="My WiFi 2.4"
    psk="mypassword123"
    key_mgmt=WPA-PSK
}

Then I plug the SD card into the Pi, boot it up, but it never appears as a client on my router, nor can I see an indication saying it's connected when I hook it up using my HDMI cable.

My WiFi settings:

enter image description here

When I plug the SD card back into the PC again, the files are missing (I assume it does its magic and applies the settings, then removes the files afterwards). However, when I look at the monitor, it shows SSH has been enabled, so I know that works.

What can I do here? I'm clueless right now.

MortenMoulder
  • 372
  • 1
  • 5
  • 14

8 Answers8

22

The accepted answer does not give a solution to anyone having this problem.

From a point on (maybe debian jessie?), the /etc/wpa_supplicant/wpa_supplicant.conf requires these lines on top of the network configs:

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

network={
    ssid="Home Wifi"
    psk="mypassword"
    key_mgmt=WPA-PSK
}

Change the country code and WiFi info to yours.

Official documentation

DaveLak
  • 105
  • 4
xavigisbeg
  • 283
  • 2
  • 8
  • 1
    Thanks. You're right, the first three lines are needed to apply the network configuration without banish the configuration every time. – antikytheraton May 27 '20 at 00:12
6

Went with PiBakery (which is awesome). Just installed Jessie Lite and I am now hooked up to the WiFi. Completely headless.

MortenMoulder
  • 372
  • 1
  • 5
  • 14
  • 2
    I don't know why your original didn't work, but the process is documented in https://raspberrypi.stackexchange.com/a/67016/8697 . This also explains where the file is located; NOTE you need `sudo` to view it. – Milliways May 28 '17 at 23:41
  • @Milliways Yeah, it's weird why it didn't work. Oh well, at least I found a solution. – MortenMoulder May 28 '17 at 23:45
  • PiBakery is very interesting. Hadn't heard of it before. Good job. – SDsolar May 29 '17 at 07:50
  • 1
    Here's a link to PiBakery: http://pibakery.org/index.html – jwfearn May 29 '17 at 17:29
4

You probably created the file "wpa_supplicant.conf" using a Windows format for end-of-line characters which the Raspberry Pi can't understand. Check to see if "wpa_supplicant.conf" has a Unix format for EOL characters. You can check this and convert ifd needed to Unix format, using a advanced editor like Notepad++ (which is free software for Windows downloadable at https://notepad-plus-plus.org).

3

This is a Raspberry Pi Zero W:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=UK
network={
 ssid="my-ssid"
 psk="my-network-password"
 key_mgmt=WPA-PSK
}

then: sudo rfkill unblock all the wifi came up and when I rebooted, to make sure, it stayed up.

Hugh Barnard
  • 151
  • 3
  • 1
    How do you run a command without first connecting to the pi? The question noted a fully headless setup. – aweyeahdawg Dec 21 '21 at 04:04
  • Hi, as the top of this thread, I created both `ssh` and `wpa_supplicant.conf` on the system where I created the boot image, **not** on the Pi Zero W. – Hugh Barnard Dec 22 '21 at 07:15
  • 1
    I was referring to when you said you ran `sudo rfkill unblock all`. In my case it was the line endings for the wpa_supplicant file were in CRLF and not LF. – aweyeahdawg Dec 22 '21 at 16:41
1

Another problem that unfortunately affects some versions of Raspbian/Rasperry Pi OS is that the rfkill status of the Wi-Fi interface is not unblocked so the wifi doesn't connect. This can be checked by logging in on the console and running:

rfkill

For the Wi-Fi to work it should show that the wlan0 device is unblocked in the the SOFT and HARD colums. If the device isn't connecting due to this issue then it will show as blocked in SOFT column.

This can only be remedied by mounting the image and changing the config as per this question, or by booting it and logging in on the console and typing:

sudo rfkill unblock wifi
Pierz
  • 794
  • 9
  • 8
1

I have found that the syntax of wpa_supplicant.conf is very picky. For example the line "priority = 1" fails whereas "prioriy=1" works. Any syntax errors will cause failure.

user462990
  • 111
  • 3
0

If you are using a Mac be sure to turn on 'Show file extensions' in Finder or the file could get a additional .txt extension wpa_supplicant.conf.txt) if created in Texteditor.

ihatetoregister
  • 140
  • 1
  • 5
-3

Dropping the wpa_supplicant.conf along with the ssh file into /boot should have worked. (I honestly don't know why it wouldn't, in your case)

Anyway, on the bright-side, you do have SSH working which is all you need to configure and control a headless Pi. Try a manually configuring wpa_supplicant directly by editing the file in /etc/wpa_supplicant/wpa_supplicant.conf. The command in the ssh terminal is as follows:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Detailed and complete instructions may be found in the reference below in the official docs.

Reference: RPi Foundation Docs: Setting wifi up via the command line

  • That's great and all, but how would I SSH into my Pi, if it's not connected to the network? And no, I won't do any crazy workaround to enable the Pi as an ethernet adapter, which I can SSH into through USB. – MortenMoulder May 31 '17 at 06:42
  • 1
    My bad, forgot that the Zeros doesn't have any other ports other than that microusb. – C.M. Au Yong Jun 04 '17 at 01:38