One of the first things
that you will want to do is to get your Raspberry Pi connected up to
In this lesson, you
will learn how to:
Connect using an
Use a WiFi adapter
with both Raspbian and Occidentalis
Find out the IP
address of your Raspberry Pi
The quickest way to get
your Raspberry Pi connected is to use an Ethernet patch cable and
just plug it into the back of your home network router.
As soon as you plug
your Pi in, you should see the network LEDs start to flicker.
For most home networks,
you should also be able to connect to the Internet without any
further configuration. For this to work, your router should be
configured for DHCP (Dynamic Host Configuration Protocol). This
service runs on your home network router, dishing out IP addresses to
any device that connects to it either through WiFi or by cable.
If DHCP is not turned
on, on your home network router, then connect to its management
console using a different computer that is already connected.
You should be able to
find a setting somewhere that turns it on.
for a WiFi adapter that supports the RTL8192cu chipset, as both the
latest Raspbian and Occidentalis distributions both have support for
this built-in and we've found its much faster than the Ralink chipsets
you already have a WiFi adapter, just give it a go, even a lot of the
very low cost budget adapters will work without any trouble.
does however use quite a lot of power, so check the power rating of
your power supply. Some WiFi adapters require an external power supply to work well. We suggest the 5V 1A power adapter in our shop if this is the case. All of the WiFi adapters we have in the Adafruit shop will work just fine this way.
you have a WiFi adapter plugged in, then you no longer have two free
USB sockets available for your keyboard and mouse, so you may also
need a powered USB hub.
Setting up WiFi requires that your router is broadcasting the SSID. Make sure you have "Broadcast SSID" set up on your router! This will not work with "private" SSID setups
Raspbian releases after 2012-10-28 include a WiFi configuration utility. You will find the shortcut for this on the Desktop. If you are using command-line tools or are logging in over Ethernet, check the next page for how to edit /boot/wpa_supplicant.conf by hand
the icon and this is what you will see.
on the Scan button and a second window will open. Find your Wireless
access point in the list and double click on it. This will open
your password in the PSK field and then click Add. When you look at
the first window, you should see that the connection is all set up
for use. You can connect or disconnect using the buttons. Notice also the IP address of the Pi is shown at the bottom of the window.
To configure Wifi you will need to edit the file /etc/wpa_supplicant/wpa_supplicant.conf. There are two ways to do this as described below. Use whichever is most convenient for your setup and situation.
With either approach, you'll want the contents of the file to be what is shown below. Replace YOURSSID and YOURPASSWORD with whatever is used for your network setup.
Don't put any spaces around the = in this file. It doesn't like that.
Create the file in /boot
This approach will allow you to configure Wifi by creating and editing the file directly on the SD card in another PC. The /boot partition is FAT formatted which is readable by most PC's. So you can simply insert the SD card in a USB reader and a boot folder should show up.
If you create a wpa_supplicant.conf file in /boot, it will be copied to the main partition's /etc/wpa_supplicant location at boot time,replacing whatever is there. It will then be deleted from /boot, so you won't see it there if you go looking.
So just use whatever text editor (not word processor) you want on your PC to create the file in /boot, like this:
Save the file and safely remove the SD card from your PC. Put it in the Raspberry Pi and power it up. If all goes well, it should copy the file over and connect to your Wifi.
Edit the file in /etc/wpa_supplicant
This is the more direct approach - you edit the file directly on the Raspberry Pi. This approach works good if you are already connected to the Raspberry Pi via a console cable or monitor.
Since this file requires elevated privileges to access, you'll need to open it with sudo.
Then add the contents. Don't forget to actually change YOURSSID and YOURPASSWORD.
Press CTRL-X and then Y to save and and exit. Then run the following command to have the file read and try to connect to your Wifi.
sudo wpa_cli -i wlan0 reconfigure
sudo wpa_cli -i wlan0 reconfigure
You can find the IP
address of your computer, either by opening the WiFi setup tool
again. The IP address will appear at the bottom of the Window.
If you are using
Occidentals, or you want to do this over a command line terminal. Open up a LXTerminal window and type the following
Next to the wlan0 entry
you will see inet addr: 192.168.1.10 which is the IP address of the
Remember! If your IP address starts with 192.168 or 10.0 then its an internal address - that means you can get OUT to the Internet but you cannot have someone outside your home or network reach your Pi via the IP address. This is important if you want to have a webserver running on a Pi that outside people can reach. In general, its much safer to keep your Pi on an internal network so it can't be hacked as easily!
If you have X running, open the Midori web
browser and navigate to the URL of your favourite electronics
If you are using a command line, the ping command can be used to see if you are reaching the internet. Try ping google.com or ping adafruit.com to check if you can reach those sites!
Fixing WiFI Dropout Issues
If you find your module 'drops out' from time to time, you can fix it fairly easily with a command line fix (thanks perseus286!)
Create and edit a new file in /etc/modprobe.d/8192cu.conf
sudo nano /etc/modprobe.d/8192cu.conf
and paste the following in
# Disable power saving
options 8192cu rtw_power_mgnt=0 rtw_enusbss=1 rtw_ips_mode=1
Then reboot with sudo reboot