2

What I want:

  • Every time the Pi starts, it should connect to the wifi
  • I should be able to ssh into it via its IP

So, after a whole day of trying and searching, I managed to finally connect to my wifi router. But, unfortunately, the connection is somehow not persistent. So here is my setup:

I ssh into my raspberry while it is connected to USB. From here I created a /etc/wpa_supplicant/wpa_supplicant.conf file with following content:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=DE
network={
  ssid="MYDEVICENAME"
  psk="MYDEVICEPASSWORD"
  key_mgmt=WPA-PSK
}
#fake network workaround for headless Raspberry Pi Zero
network={
  ssid="fakessid"
  psk="fakepass"
  key_mgmt=WPA-PSK
}

I don’t really remember where I got this from but it seems to work. Because I had no idea if it is relevant and saw both locations used, I copied the exact same thing one directory up to /etc/wpa_supplicant.conf (is that even necessary?)

I rebooted, but the Pi did not connect to the wifi by itself. So I found this command online:

sudo wpa_supplicant -iwlan0 -c/etc/wpa_supplicant.conf -Dwext -B

which did connect my Pi to the internet. I also can ssh into it. I also have internet as I can clone an online repo. I can’t apt-update but I guess that’s probably a topic on its own.

But everytime I unplug it or reboot it, it won’t connect automatically and I’ll have to retype the above command.

How can I have the Raspberry Pi zero w connect to that network automatically every time it gets turned-on/booted?

I feel like it’s just one last small piece missing

Thank you!

  • 1
    You may have followed some other advice and modified other files, You should check How to set up networking/WiFi and list any changes you made. The "fake" stuff does no harm, but is unnecessary - this was just to opinion of one user. You should only have 1 /etc/wpa_supplicant/wpa_supplicant.conf – Milliways Nov 11 '17 at 1:16
  • 1
    You can't apt-update because there is no such command. – Milliways Nov 11 '17 at 1:17
1

Ok, I don’t know why but now it’s working, here is what I did:

I added this file:

sudo nano /etc/wpa_supplicant/wpa_supplicant/conf

and placed these information inside:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=DE
network={
  ssid="MYDEVICENAME"
  psk="MYDEVICEPASSWORD"
  key_mgmt=WPA-PSK
}
#fake network workaround for headless Raspberry Pi Zero
network={
  ssid="fakessid"
  psk="fakepass"
  key_mgmt=WPA-PSK
}

only changing MYDEVICENAME and MYDEVICEPASSWORD to the correct values. I guess for others the country code might also have to be edited.

And then rebooting with

sudo reboot

I never used that command before but always rebooted using sudo /sbin/shutdown -r now, so it could also be that a proper sudo reboot what was needed.

So I have these settings now at 3 locations (/etc/wpa_supplicant/wpa_supplicant.conf, /etc/wpa_supplicant/wpa_supplicant.conf and /etc/wpa_supplicant/wpa_supplicant/conf) and also it feels as if I have to much information in these setting files.

I’m happy with the solution for now (after like 6 hours) but I’ll investigate this further (what is really needed).

Oh yes and I also found this link: https://www.piborg.org/blog/pi-zero-wifi-bluetooth and this one: https://brandonb.io/raspberry-pi-zero-w-headless-setup-on-macos maybe it helps someone.

  • You dont need wpa_supplicant/conf you just needed to reboot after making the changes to /etc/wpa_supplicant/wpa_supplicanr.conf. – Steve Robillard Nov 11 '17 at 1:29

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.