Posts tagged: wifi

Raspberry Pi WiFi via USB

I’ve been playing with my Raspberry Pi again. Actually, I ordered a Pi Zero and a Pi 3 as well.

I really didn’t need the Pi Zero. It was a bit of a Black Friday impulse purchase. Ordered it from Pimoroni in the UK and took just about a month to arrive. On a related note, Amazon Canada had better Pi 3 deals during Black Friday than they did for Boxing Day (I’m looking at you, Canakit).

I’m still waiting on the Zero4U (USB board) I ordered for the Pi Zero and I don’t have any microUSB adapters so the Zero is sitting unused in its antistatic bag. By coincidence, both the Pi Zero I ordered from the UK and the USB WiFi dongles I ordered from China arrived on the same day.

All that aside, both my 1st gen Pi Model B and the Pi Zero need WiFi capabilities. I barely use my Model B because it’s a nuisance to plug it in where my router is.

Here’s how I got wifi working on my Pi. Credit goes to the two articles I found here and here, because the first article mostly worked, and the second article had the command to actually connect to my access point.

From the pi command line:

wpa_cli
add_network

It’ll give you a number. 0 in my case.

scan
scan_results

Locate the access point you want to connect to.

set_network 0 ssid "your-access-point"
set_network 0 psk "the-passphrase-goes-here"

The first article tells me the Pi should connect to the network now. Mine didn’t. So the second article says to

select_network 0

Provided your settings are correct it should connect. Now to figure out how to connect every time the Pi is rebooted.

Getting it to connect on startup

Turns out wpa_cli wasn’t enough. Or if it is sufficient, I’m missing steps to add the required values. According to this other article you need to edit the wpa_supplicant config.

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

I then added the lines that were missing from mine and actually deleted one (disabled=1).

EDIT: In the case of my Pi Zero I actually had to type out the entire block below.

network={
ssid="YOUR_NETWORK_NAME"
psk="YOUR_NETWORK_PASSWORD"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP
auth_alg=OPEN
}

I then added a required line to the network interfaces file.

sudo nano /etc/network/interfaces

Which required the following line added somewhere near the top (I put it just below auto lo).

auto wlan0

The Pi now connects to my network after a reboot.

Trendnet TEW 423pi wifi and Ubuntu 10.04

I’ve spent parts of the last 24 hours trying to get wifi running on my desktop (I primarily use my work laptop). The desktop uses a cheapo Trendnet TEW 423pi (revision C1.xR).

After bashing my head against my desk following the Ubuntu Community instructions to installing ndiswrapper and Windows wifi drivers, and finding that the wireless networking still doesn’t work, I find a simple solution to my problem. I notice the network-manager, for both the wired and wireless connections, when clicked on displays: wireless networks device not managed.

A quick google search for ubuntu wireless networks device not managed and I find the simple solution. The solution was found at post #8 of this thread.

Changing [ifupdown] managed=false to true in /etc/NetworkManager/nm-system-settings.conf resolved the issue.

Wifi at boot

Some people may have noticed that wifi doesn’t exactly turn itself on until the user has logged in to the desktop. That’s a problem for some users. How is it a problem? It gets in the way of remote administration.

If I’m at work and am remotely logged in to my home PC (via SSH, for example) then there may come a time when I want to reset my PC. If my wireless does not turn itself on when the PC turns on then I end up with a PC turned on at home, not connected to the internet, and no one around to log in for me.

Note: In the following example, your wifi card may not be recognized as “wlan0”. Type “ifconfig” to see what yours may be. Substitute whatever yours is in place of wlan0.

How do you connect to a wireless access point from the command line?

First, you “turn on” your wireless card

sudo ifconfig wlan0 up

Now you should be able to

sudo iwlist wlan0 scan

which will show you all the wifi access points within range. The wifi card needs to know which access point to connect to. This is done by

sudo iwconfig wlan0 essid WhateverAPYouAreConnectingTo

and if it uses a (WEP) key then set the key

sudo iwconfig wlan0 key WhateverTheKeyIs

But you’re not connected yet. You need to establish the PC’s IP address within the network

sudo dhclient

and you’re set. You should see “bound to 192.168.x.x — renewal blah blah blah” as the last line. Test the connection

ping google.com

and you see that packets are being transmitted and received.

So how do you set that automatically? Stick the commands in your /etc/rc3.d/S99rc.local file, at the very bottom.

...blah blah...
esac

# Added on this date to get wifi on bootup
ifconfig wlan0 up
iwconfig wlan0 essid WhateverMyAccessPointIsCalled
iwconfig wlan0 key WhateverMyKeyIs
dhclient

Now every time you restart your computer, your computer will be connected to the network before you even log in.

Take a look at this article for some explanation of what rc.d scripts do.

Staypressed theme by Themocracy