I have an Edimax EW-7811Um USB wifi dongle, and I regularly follow the instructions here:
https://github.com/retropie/RetroPie-Setup/wiki/Wifi#method-1-easiest
The problem that I encounter is that when performing the initial setup, it regularly fails after I enter my wifi password. My solution is to just keep trying until finally the script recognizes that it connected successfully. It can typically take anywhere from 3 to 7 attempts before it’s successful. From that point on, the system has zero trouble connecting immediately.
This makes me wonder if there isn’t perhaps a timeout problem or something in the script when it tries to determine if the initial connection was successful or not.