In this post we will see how to connect the Raspberry Pi board to a wireless network through the Edimax WiFi adapter. You can easily find this dongle on Amazon for less than 10 bucks. It’s a perfect solution for your Raspberry Pi IOT projects!
Wireless configuration
Plug in the adpater and check whether the wifi dongle has been recognized by the kernel. You should see the following output:
userk@dopamine:~$ dmesg | tail -10
[ 152.812434] usb 1-1.4: new high-speed USB device number 7 using dwc_otg
[ 152.914094] usb 1-1.4: New USB device found, idVendor=7392, idProduct=7811
[ 152.914131] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 152.914146] usb 1-1.4: Product: 802.11n WLAN Adapter
[ 152.914160] usb 1-1.4: Manufacturer: Realtek
[ 152.914215] usb 1-1.4: SerialNumber: 00e04c000001
Network connection
Let’s consider we want to connect the network called “Android-AP” with password “myHotSpot”.
Make a security copy of the actual configurations and modify the interfaces file stored in the /etc/network folder.
userk@dopamine:~$ sudo cp /etc/network/interfaces /etc/network/interfaces.bk
userk@dopamine:~$ sudo vim /etc/network/interfaces
We will see the follwing configurations.
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
allow-hotplug wlan0
auto wlan0
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
Press ‘a’ to modify the file and use the arrows to move around. Let’s change it to
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
allow-hotplug wlan0
auto wlan0
iface wlan0 inet dhcp
wpa-ssid "Android-AP"
wpa-psk "myHotSpot"
# wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
# iface default inet dhcp
Once edited, press ESC and “:wq” to save and exit Vim.
Now restart the network interface and the job is done. Verify that you are now connected to the wlan0 interface and you obtained your Ip address.
userk@dopamine:~$ sudo service networking restart
[...]
userk@dopamine:~$ ifconfig
wlan0 Link encap:Ethernet HWaddr 74:da:38:05:30:2a
inet addr:192.168.43.235 Bcast:192.168.43.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4492 errors:0 dropped:8 overruns:0 frame:0
TX packets:3237 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:5755376 (5.4 MiB) TX bytes:355872 (347.5 KiB)
tit