There are several years' worth of setting up the Edimax EW-7811N Wi-Fi adapter on a Raspberry Pi B on the internet. By now (2017) most of it is out of date and wrong. Last week, I wasted several hours trying to make WPA2 authentication work on my Raspberry Pi B. Hopefully this guide will save someone (or future me) some time.
My Hardware

- Edimax EW-7811N
- Raspberry Pi B Revision 2
- Rapbian Jessie Lite 1/11/2017
Getting Started
Roll back any changes you have made to the /etc/network/interfaces or /etc/wpa_supplicant/wpa_supplicant.conf files. I usually make .bak copies of config files before I make changes. However, if you did not make backups of these files, the contents of each original file is below.
/etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
#iface eth0 inet manual
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
/etc/wpa_supplicant/wpa_supplicant.conf
country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
Additionally, I had installed WICD at some point while trying to configure the adapter. WICD will eat up to 5% of CPU in idle so you will want to uninstall it if you journeyed down the same rabbit hole I did...
RESTART
Before continuing (and wasting more of your precious time) RESTART your Pi (sudo reboot or sudo shutdown -r now). I probably wasted another 30 minutes with a working solution because I hadn't restarted...
USB?
Make sure the Wi-Fi adapter is plugged in and showing via the lsusb command:

The Wi-Fi adapter should be show as "Edimax Technology Co..." as per above. If it is not showing up, try unplugging and plugging in the adapter and/or restarting.
Setting Up WPA2
To set up WPA2 authentication, you will only need to edit the /etc/wpa_supplicant/wpa_supplicant.conf file. Edit this file with the following:
country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="YOURNETWORKSSIDHERE"
psk="YOURPASSWORDHERE"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP
group=CCMP
auth_alg=OPEN
}
Replace YOURNETWORKSSIDHERE with your SSID and YOURPASSWORDHERE with your Wi-Fi password.
At this point restart your Pi.
Once your Pi has restarted fully, run the ifconfig command to confirm your adapter is getting an IP address. The wireless link should be next to wlan0 or wlan1 in the dump:

No Sleep
Finally, if your Pi needs to have Wi-Fi on at all times, be sure to disable power management by creating or editing the /etc/modprobe.d/8192cu.conf file via sudo nano /etc/modprobe.d/8192cu.conf:
# Disable power management
options 8192cu rtw_power_mgnt=0 rtw_enusbss=0
After this change, restart your Pi again.
Conclusion
I you found this guide helpful and hopefully it saved you some time! Until next time - happy coding!