Adafruits Raspberry Pi Lesson 3 Network Setup
Adafruits Raspberry Pi Lesson 3 Network Setup
Network Setup
Created by Simon Monk
Guide Contents Guide Contents Overview Using a Wired Network Buying a USB WiFi Adapter Setting up Wifi with Raspbian Setting up Wifi with Occidentalis Finding Your Pi's IP Address Test and Configure 2 3 4 6 7 12 15 16
Page 2 of 16
Overview
One of the first things that you will want to do is to get your Raspberry Pi connected up to the Internet. In this lesson, you will learn how to: Connect using an Ethernet cable Use a WiFi adapter with both Raspbian and Occidentalis Find out the IP address of your Raspberry Pi
Page 3 of 16
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.
Page 4 of 16
Page 5 of 16
WiFi 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 (http://adafru.it/501). All of the WiFi adapters we have in the Adafruit shop will work just fine this way. If 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. (http://adafru.it/961)
Page 6 of 16
Page 7 of 16
Step 1. Double-click the icon and this is what you will see.
Page 8 of 16
Step 2. Click 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 another window.
Page 9 of 16
Step 3. Enter 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.
Page 10 of 16
Page 11 of 16
Step 1. Boot the Raspberry Pi without the WiFi adapter plugged in.
Step 2. Open a Terminal session by clicking on the LXTerminal icon, and enter the following command into it:
Step 3. This opens an editor screen of the wifi configuration file you need to change.
Page 12 of 16
The two places where you need to make a change are on the last two lines. Change the file so that it looks like this:
Of course, you should put in yo ur network and password! Note that you need to keep the double-quote characters around your wireless network name and password. This kind of editor does not let you use the mouse. Instead, use the cursor keys to move around the file.
Step 4. When you have finished press [ctrl]x. This will ask if you want to save the modified files.
Page 13 of 16
Press 'Y' and then Return to save the file with the same name.
Step 5. Shut down your Raspberry Pi, plug the WiFi adapter in and start it up again. You should find that the Raspberry Pi connects using the WiFi adapter as it boots up.
Page 14 of 16
sudo ifconfig
Next to the wlan0 entry you will see inet addr: 192.168.1.10 which is the IP address of the Raspberry Pi.
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!
Page 15 of 16
If you are using a command line, the ping command can be used to see if you are reaching the internet. Try ping go o gle.co m or ping adafruit.co m to check if you can reach those sites!
Adafruit Industries
Page 16 of 16