Why won’t my Raspberry Pi connect to Wi-Fi?

I recently set up a new Raspberry Pi, but Wi-Fi didn't work out of the box. The answer turned out to be that my Wi-Fi dongle was too old for the new driver, so I had to update a configuration file to use the older driver. These are a few notes on things I learned.

To connect to Wi-Fi, a Linux system uses a daemon service called wpa_supplicant that handles authentication to the access point. The SSID, password, and other information are generally stored in a configuration file /etc/wpa_supplicant/wpa_supplicant.conf. The service is run through systemd, configured in /lib/systemd/system/wpa_supplicant.service.

Following many other instructions, I first added the access point authentication information manually to the wpa_supplicant configuration. When that didn't help, I tried running wpa_supplicant manually, which gave me an error:

nl80211: Driver does not support authentication/association or connect commands

According to this post, that meant that I had to use the wext driver rather than the newer nl80211 driver for wpa_supplicant, which I changed by adding the -D option to the systemd configuration.

The daemon also needs a control communication channel (to instruct it to scan for networks, connect, etc.). There are two types of communication channels. First, wpa_supplicant can use socket files, which are configured in the configuration file. Second, it can use the dbus messaging system.

On the Raspberry Pi, the dbus mechanism is the default (the systemd configuration file contains a -u option). But for some reason I couldn't get that to work, so I switched over to the socket file mechanism. The resulting configuration was as follows:

ExecStart=/sbin/wpa_supplicant -i wlan0 -D nl80211,wext -c /etc/wpa_supplicant/wpa_supplicant.conf

I also changed the service type to simple rather than dbus. Ideally dbus would work but this is good enough for now.