Sunday, February 3, 2013

Web connected outlet - part 5

Headless WiFi Pi

Hooking up wireless on the Pi is pretty easy.  Here's the high-level process:
- Start out by connecting a monitor, keyboard and a downloaded image on your SD card
- During configuration, select that you want SSH installed and running
- Hook up your ethernet connection
- Reboot
- Log in via the keyboard and do an ifconfig to get the IP address of the Ethernet adapter (or just monitor your router during the reboot to see what new IP address shows up. Ethernet defaults to dhcp so you can't predict what IP address it will be...)
- ssh from your computer to the IP address of the Ethernet adapter.  I use this with the password raspberry
All wired up - sans case.
Don't touch anything!
ssh pi@192.168.1.27
- modify /etc/network/interfaces so it looks something like this:
auto lo
iface lo inet loopback
 
auto wlan0
iface wlan0 inet static
wireless-essid [your-wifi-ssid]
address 192.168.1.210
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 192.168.1.1 8.8.8.8
 
auto eth0
iface eth0 inet dhcp
- plug in your WiFi USB device into the empty USB port on the RPi
- reboot and disconnect your wired connection, keyboard and monitor - you're WiFi headless now.
- you should now be able to connect to the IP address you set up above. (You can always reconnect the wired Ethernet, or connect a monitor and keyboard if something goes wrong.)

Obviously, you'll want to use your own network's ssid and IP subnet.  For these devices, I use an unprotected WiFi network (you'll probably want to use WPA.)  There are lots of good Raspberry Pi wireless configuration resources; just google it...

Note that eth0 follows wlan0 in the file, above. I did this because, if it's not connected to anything, the eth0 connection continuously tries to connect and may just sit there waiting for a long, long time, before the wireless connection gets configured [at least this is my speculation - I couldn't get a wireless connection until I moved eth0 down.]


The WiFi USB device I'm using I got from Newark.com for about $16 [at left.] (For some reason, at this time, the picture on the Newark web page shows something different than what you actually get. View the "Technical Data Sheet" for an image of the actual device.)  I've used a couple of other small USB wireless adapters, but found that this one seems to be most reliable. One of the others apparently had a short and was actually smoking when I pulled it out of the USB port (with my bare hands, BTW. You gotta be tough to be a geek.)


Next time: the web page.

No comments:

Post a Comment