monkeytrump
Posts: 3
Joined: Fri Jan 26, 2018 7:06 pm

pi zero w wpa_supplicant

Fri Jan 26, 2018 7:20 pm

Hi, I'm pretty new to this and I'm struggling. I have managed to set up raspian stretch headless, and after some messing around managed to get an SSH connection over usb, albeit oddly using ipv6, i don't know why. My problem is that my wpa_supplicant file doesn't seem to work. I've tried following all sorts of guides, mostly involving creating the file in the root of the sd card, changing the EOL conversion to unix, and rebooting the pi. This does seem to do all the right things, the file gets copied to the right location, but thats all. I've even tried creating the file using nano directly from the command line. The odd thing is that if i go into raspi-config and try to set up the wifi from there, i get an error 'cannot communicate with wpa_supplicant'

Anyone got any ideas?

mattmiller
Posts: 2099
Joined: Thu Feb 05, 2015 11:25 pm

Re: pi zero w wpa_supplicant

Fri Jan 26, 2018 10:54 pm

1. Do you have full raspbian or just the lite version (full is much easier to setup wifi without having a previous working Pi)

2. Can you post output of cmd

Code: Select all

cat /proc/cpuinfo
3. And of course post your wpa_supplicant.conf file (just replace password with x)

User avatar
HawaiianPi
Posts: 4531
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: pi zero w wpa_supplicant

Sat Jan 27, 2018 11:42 am

This is the procedure I use for setting up headless boot with SSH and wireless network. It works with Raspbian Jessie or Stretch, Desktop or Lite, and with the built-in WiFi on the Pi3B & Zero W, or a Raspbian compatible USB WiFi dongle on other models (tested on an old model B, Pi2 and Pi Zero). Everything is done before you boot the SD card, and can be done on a Windows or Mac computer which only has access to the small FAT32 "boot" partition of a Raspbian imaged SD card.
  1. Grab the latest Raspbian image from https://www.raspberrypi.org/downloads/raspbian/
  2. Grab the Etcher software from https://etcher.io/
  3. Install Etcher and use it to write the Raspbian image to your SD card. You don't need to extract the image or format the card prior to writing. Just choose the Raspbian .zip, pick your SD card and write (if you have trouble, verify the SHA256 checksum of the download).
  4. Remove and reinsert the SD card so that your Windows or Mac PC can see the small FAT32 partition on the SD card (labelled "boot").
    If you get a message telling you the card must be formatted, cancel it.
  5. On the small FAT32 "boot" partition, create a file with the name ssh (or ssh.txt). It can be empty, the contents don't matter.
  6. If you are connecting the Pi to your router with an Ethernet cable, you can eject the card and use it to boot your Pi now.
  7. To connect to a wireless network, create another file on the card called wpa_supplicant.conf, which has the following inside:

    Code: Select all

    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    update_config=1
    country=US
    
    network={
         ssid="Your network name/SSID"
         psk="Your WPA/WPA2 security key"
         key_mgmt=WPA-PSK
    }
    Edit country=, ssid= and psk= with your information and save the file.
  8. Make sure that both files are in the root directory of the small FAT32 partition, not in any folder.
  9. Safely eject the card from your PC and use it to boot the Pi.
If Raspbian finds an ssh file it will enable SSH and delete the file. If it finds a wpa_supplicant.conf file, it will move it to its correct location and connect to your wireless network. Give your Pi some time to boot and connect to your network (the first boot always takes a bit longer), then you should be able to SSH into the Pi and configure it how you like.

If you have attempted this and failed then unplugged the power to turn off your Pi, you should start over with a freshly imaged card. Improperly powering down the Pi can cause SSH key generation to fail, which will prevent SSH logins.

If you believe you have done all of this correctly, then some additional information might help us figure out what's going on.
  • What kind of computer are you using to create and edit the SD card (Windows, Mac, Linux)?
  • What software are you using to create/edit the ssh and wpa_supplicant.conf files?
  • How are you writing the SD card (did you use Etcher to both extract and write the image)?
  • Did you verify the SHA256 checksum of the download?
  • Make, model, size of SD card?
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

monkeytrump
Posts: 3
Joined: Fri Jan 26, 2018 7:06 pm

Re: pi zero w wpa_supplicant

Sat Jan 27, 2018 5:35 pm

Well as far as I can tell, I did exactly the steps as you described. I'm starting from scratch again, just to make sure I didn't do anything silly. I'm using etcher, this time I'm not extracting the zip file to an image, just using the zip directly. I downloaded stretch from this site, full, not the lite version. my WPA_supplicant file looks like

network={
ssid="xx"
psk=“xx”
key_mgmt=WPA-PSK
}

[*] I'm using windows 10 64
[*] for the wpa_supplicant file I used notepad++ and changed the EOL conversion to 'unix(LF)', for the ssh file i just right clicked, created a new .txt file, deleted the extension and named it ssh
[*] I'm using etcher to extract and flash the card
[*] I didn't veryify the SHA checksum
[*] My sd card is a new sandisk ultra 16GB microSDHC

[email protected]:~ $ cat /proc/cpuinfo
processor : 0
model name : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS : 697.95
Features : half thumb fastmult vfp edsp java tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xb76
CPU revision : 7

Hardware : BCM2835
Revision : 9000c1
Serial : 00000000a4424e7a

Just set it up again and still can't communicate with WPA_SUPPLICANT.

mattmiller
Posts: 2099
Joined: Thu Feb 05, 2015 11:25 pm

Re: pi zero w wpa_supplicant

Sat Jan 27, 2018 6:16 pm

You need your wpa_supplicant.conf file to look like the one @HawaiianPi posted above your last post

User avatar
B.Goode
Posts: 8247
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: pi zero w wpa_supplicant

Sat Jan 27, 2018 6:20 pm

monkeytrump wrote:
Sat Jan 27, 2018 5:35 pm
Well as far as I can tell, I did exactly the steps as you described. I'm starting from scratch again, just to make sure I didn't do anything silly. I'm using etcher, this time I'm not extracting the zip file to an image, just using the zip directly. I downloaded stretch from this site, full, not the lite version. my WPA_supplicant file looks like

network={
ssid="xx"
psk=“xx”
key_mgmt=WPA-PSK
}
That is NOT exactly like the sample content suggested by @HawaiianPi. Have a look at Step 7 again.

monkeytrump
Posts: 3
Joined: Fri Jan 26, 2018 7:06 pm

Re: pi zero w wpa_supplicant

Sat Jan 27, 2018 6:24 pm

Ah, that fixed it! superb, thanks very much!

User avatar
B.Goode
Posts: 8247
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: pi zero w wpa_supplicant

Sat Jan 27, 2018 6:40 pm

monkeytrump wrote:
Sat Jan 27, 2018 6:24 pm
Ah, that fixed it! superb, thanks very much!
The thanks are due to @HawaiianPi. His guide is accurate.

User avatar
HawaiianPi
Posts: 4531
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: pi zero w wpa_supplicant

Sat Jan 27, 2018 10:27 pm

That truncated version of wpa_supplicant.conf used to work with Jessie, but no longer works with Stretch. When you configure WiFi using the GUI it creates all the lines I posted in my example, so that's what I recommend using. At some point during the release of Jessie someone figured out that only the network section was needed, and as a result there are tons of guides around that are no longer valid for Stretch.
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

redlinesprint
Posts: 12
Joined: Sat Dec 01, 2018 7:36 pm

Re: pi zero w wpa_supplicant

Mon Dec 03, 2018 3:30 am

So I am struggling hard with this. I am using Stretch lite and cant seem to get my wifi to work no matter what ive tried. When it boots up I have a status of "fail" for Start Raise network interface. I have rebuilt the wpa supplicant file as the "complete" one with the country=US and the dir=/var/ stuff but i must be missing something. I can take a picture of what my wpa supplicant file looks like if that helps.

Ive been bangin my head against the wall for a few days now so any help would be appreciated!

DirkS
Posts: 9901
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: pi zero w wpa_supplicant

Mon Dec 03, 2018 10:10 am

redlinesprint wrote:
Mon Dec 03, 2018 3:30 am
I can take a picture of what my wpa supplicant file looks like if that helps.
Please post it as text in a code block. Edit out the password.

redlinesprint
Posts: 12
Joined: Sat Dec 01, 2018 7:36 pm

Re: pi zero w wpa_supplicant

Mon Dec 03, 2018 3:27 pm

Here is the output when i run:

Code: Select all

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Code: Select all

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

network={
	ssid="ssid"
	psk="password"
}
Last edited by redlinesprint on Mon Dec 03, 2018 5:37 pm, edited 1 time in total.

redlinesprint
Posts: 12
Joined: Sat Dec 01, 2018 7:36 pm

Re: pi zero w wpa_supplicant

Mon Dec 03, 2018 3:43 pm

whenever I try to configure anything network related using the sudo raspi-config menu it says "Could not communicate with wpa_supplicant". So I cant pick my ssid from a list or change my country code or download or update / upgrade anything.

DirkS
Posts: 9901
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: pi zero w wpa_supplicant

Mon Dec 03, 2018 4:39 pm

redlinesprint wrote:
Mon Dec 03, 2018 3:43 pm
whenever I try to configure anything network related using the sudo raspi-config menu it says "Could not communicate with wpa_supplicant". So I cant pick my ssid from a list or change my country code or download or update / upgrade anything.
To test I I would get a spare SD card and put the latest Raspbian (Lite) on it (not Noobs) and see if that works.
Don't make any mods except adding wpa_supplicant.conf

User avatar
mooblie
Posts: 125
Joined: Fri Oct 14, 2016 2:07 pm
Location: The Scottish Highlands

Re: pi zero w wpa_supplicant

Mon Dec 03, 2018 4:53 pm

redlinesprint wrote:
Mon Dec 03, 2018 3:27 pm
Here is the output when i run:

Code: Select all

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Code: Select all

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

network={
	ssid"ssid"
	psk="password"
}
Isn't this wpa_supplicant.conf file missing a "=" on the ssid line?

DirkS
Posts: 9901
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: pi zero w wpa_supplicant

Mon Dec 03, 2018 5:12 pm

mooblie wrote:
Mon Dec 03, 2018 4:53 pm
redlinesprint wrote:
Mon Dec 03, 2018 3:27 pm
Here is the output when i run:

Code: Select all

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Code: Select all

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

network={
	ssid"ssid"
	psk="password"
}
Isn't this wpa_supplicant.conf file missing a "=" on the ssid line?
Indeed it is. Although it could be that poster botched up when editing out the real ssid

redlinesprint
Posts: 12
Joined: Sat Dec 01, 2018 7:36 pm

Re: pi zero w wpa_supplicant

Mon Dec 03, 2018 5:36 pm

DirkS wrote:
Mon Dec 03, 2018 5:12 pm
mooblie wrote:
Mon Dec 03, 2018 4:53 pm
redlinesprint wrote:
Mon Dec 03, 2018 3:27 pm
Here is the output when i run:

Code: Select all

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Code: Select all

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

network={
	ssid"ssid"
	psk="password"
}
Isn't this wpa_supplicant.conf file missing a "=" on the ssid line?
Indeed it is. Although it could be that poster botched up when editing out the real ssid
Correct. I made a mistake when posting output. My nano output does indeed have the = between ssid and "ssid".

I tried a fresh install with just the wpa_supplicant.conf to same result.

redlinesprint
Posts: 12
Joined: Sat Dec 01, 2018 7:36 pm

Re: pi zero w wpa_supplicant

Mon Dec 03, 2018 5:38 pm

I corrected my original code to reflect the exact nano output.

User avatar
HawaiianPi
Posts: 4531
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: pi zero w wpa_supplicant

Mon Dec 03, 2018 7:44 pm

redlinesprint wrote:
Mon Dec 03, 2018 3:30 am
So I am struggling hard with this. I am using Stretch lite and cant seem to get my wifi to work no matter what ive tried...
First of all, are you sure it's a Pi Zero W and not just a Pi Zero?

What is the output of the following command?

Code: Select all

cat /sys/firmware/devicetree/base/model;echo
What is your main PC (Windows, Mac, OS version)?

What are you using to create or edit the wpa_supplicant.conf file?

Are you using the latest version of Raspbian Stretch from https://www.raspberrypi.org/downloads/raspbian/?

Are you altering anything else on the Raspbian card (static IP, interface settings, config/cmdline.txt, etc.)?

Does your router or gateway have any additional security settings (like DHCP or MAC address limits)?
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

redlinesprint
Posts: 12
Joined: Sat Dec 01, 2018 7:36 pm

Re: pi zero w wpa_supplicant

Mon Dec 03, 2018 8:46 pm

so I was able to sorta get it working.

I changed Country to country and US to us. when I did this in the Pi3 it worked like a charm.

disconnected the ethernet cable and it was working via wifi.

I take the card from the 3 and put it in the zerow and no dice.

MrEngman
Posts: 3843
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: pi zero w wpa_supplicant

Mon Dec 03, 2018 9:04 pm

redlinesprint wrote:
Mon Dec 03, 2018 8:46 pm
so I was able to sorta get it working.

I changed Country to country and US to us. when I did this in the Pi3 it worked like a charm.

disconnected the ethernet cable and it was working via wifi.

I take the card from the 3 and put it in the zerow and no dice.
The country code, us, should be in capital letters, US.
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

redlinesprint
Posts: 12
Joined: Sat Dec 01, 2018 7:36 pm

Re: pi zero w wpa_supplicant

Mon Dec 03, 2018 9:31 pm

HawaiianPi wrote:
Mon Dec 03, 2018 7:44 pm
redlinesprint wrote:
Mon Dec 03, 2018 3:30 am
So I am struggling hard with this. I am using Stretch lite and cant seem to get my wifi to work no matter what ive tried...
First of all, are you sure it's a Pi Zero W and not just a Pi Zero?

What is the output of the following command?

Code: Select all

cat /sys/firmware/devicetree/base/model;echo
What is your main PC (Windows, Mac, OS version)?

What are you using to create or edit the wpa_supplicant.conf file?

Are you using the latest version of Raspbian Stretch from https://www.raspberrypi.org/downloads/raspbian/?

Are you altering anything else on the Raspbian card (static IP, interface settings, config/cmdline.txt, etc.)?

Does your router or gateway have any additional security settings (like DHCP or MAC address limits)?
Main OS was windows 10. Wpa_supplicant was made using notepad++ changed eol to unix.

Output of that code shows Raspberry Pi Zero W Rev 1.1

Yes to latest Stretch. Altered /etc/network/interfaces to include the following:

Code: Select all

auto wlan0
iface wlan0 inet manual
iface default inet dhcp
No additional security settings.

Like i said i had it working on my pi3 but it wouldnt work in Zero W

DirkS
Posts: 9901
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: pi zero w wpa_supplicant

Mon Dec 03, 2018 9:33 pm

redlinesprint wrote:
Mon Dec 03, 2018 9:31 pm
Yes to latest Stretch. Altered /etc/network/interfaces to include the following:

Code: Select all

auto wlan0
iface wlan0 inet manual
iface default inet dhcp
Read the first couple of lines of that file.
Then undo these changes and reboot
(unless you made other changes such as removing dhcpcd5, but then you should have mentioned that too)

MrEngman
Posts: 3843
Joined: Fri Feb 03, 2012 2:17 pm
Location: Southampton, UK

Re: pi zero w wpa_supplicant

Mon Dec 03, 2018 9:41 pm

Using Raspbian Stretch you should not edit file /etc/network/interfaces. If you do it can mess up the networking.

File /etc/network/interfaces should be left like

Code: Select all

# 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
On my Pi 0 W file /etc/wpa_supplicant/wpa_supplicant.conf is like

Code: Select all

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

network={
        ssid="network-name"
        psk="network-password"
        key_mgmt=WPA-PSK
}
I use the same configuration on all my other Pi's 3A+, 3B+, 3, 2B+, B+, B and 0 running Raspbian Stretch.
Simplicity is a prerequisite for reliability. Edsger W. Dijkstra

Please post ALL technical questions on the forum. Please Do Not send private messages.

User avatar
HawaiianPi
Posts: 4531
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: pi zero w wpa_supplicant

Mon Dec 03, 2018 10:39 pm

Don't mess with /etc/network/interfaces.

I've been using the same wpa_supplicant.conf file for a few years now and it has worked for me on the Pi 3B, 3B+, Zero W and other models with a Raspbian compatible USB WiFi dongle. Note case of everything in my example file.

Code: Select all

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

network={
	ssid="Your network SSID"
	psk="Your WPA/WPA2 security key"
	key_mgmt=WPA-PSK
}
Linux is case sensitive, so filenames also need to be correct case, and Windows has a nasty habit of adding .txt to text files, but hides that extension by default. Turn off the Hide known file extensions option in Windows.

Odd that it works in the Pi3 and not in the Zero W...

What are you using for power supplies on both?

Start with a freshly imaged 2018-11-13 Raspbian Stretch with Desktop card in the Pi3, configure WiFi using the GUI (no manual editing of anything), and then move that card over to the Zero W. If that doesn't work then your Zero W is suspect.
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

Return to “Troubleshooting”