I'm an Algebra teacher, not a computer whiz, but I had to get into problem solving mode because I've been having these problems for 6 months. No, they don't fix themselves. Here are specifics and, I think, the fix.
When I brought the iPhone 5 home, all of a sudden, 50% of the time, my iMac refused to connect to WiFi in my own home. It kept telling me my connection was "timed out." But all the lights were green. I had to go through the process of unplugging the Airport Express a few times, fiddling with Network Preferences, password over and over until it connected. Meanwhile, the iPhone5 would also 50% of the time hook into my home Wifi and 50% of the time run on 3G from Verizon. Whenever I tried to select my home network, it wouldn't allow me to. I've never been able to even enter my network password into my phone. On selected days when the wifi was working for phone and imac, I'd go to work, my phone would switch to 3G (because I don't like to join other networks due to privacy) and when I'd come home, the iMac and phone 50% of the time would refuse to connect.
I called Apple. The Airport Express guy reset that (putting a pin in the tiny little rubber circle, etc.). Didn't work. Called iMac specialist. He helped me rename and repassword my network, changed my security from WEP 128 bit (which is NOT secure) to WPA/WPA2 Personal. Didn't work but at least the network is now more secure. Who knew! Called the iPhone5 guys several times. They reset my phone. No go. I was too busy with the kids at work to keep this potluck party going. Now I'm on vacation. Buckle your seatbelts, boys.
Here's what I think fixed it. This first remedy fixed it only for a couple of days, so if you're in a hurry, skip 1-3 and go directly to 4-7 below. But if 4-7 doesn't stick, then try them together.
1. Connect iPhone to iMac by using the USB part of the iPhone's cord.
2. Open up iTunes (even if you're not online). The phone appears on left side of iTunes window. If you don't see the phone, hit View, Show Sidebar, and under "Devices" choose your phone. A menu of choices appears. Click "Sync this iPhone over Wifi." You can also back up your phone if you want.
3. See if you can now connect to home Wifi.
Here's the remedy from a random Airport Express guy at Apple. He knew nothing about the iPhone, but did this since it's the only thing I hadn't done. Had this not worked, yes, I would have gotten a new iPhone. I'm writing out the unsophisticated version to help out the most people, so hang in there programmer heads.
4. Go to your laptop or iMac's Spotlight (magnifying glass, upper right on screen) and type in Airport Utility. Open it. If you can't find it, open your Applications folder, then Utilities, then Airport Utility. Open it.
5. Choose your network. Aslo make sure your base station is found (you see the base station's icon). If it's not there because you're not connected to Wifi (happened to me), keep trying.
6. Continuing on Airport Utility, go to the "Wireless" tab. On Wireless Security, choose "WPA/WPA Personal" for better security. On "channel" my channel was Automatic, but changing that fixed everything. Here's how.
7. Leave Airport Utility up (we'll get back to it soon). Go to the Apple icon on the top left of laptop or iMac. Choose "about this Mac" then hit "More info." A windo will appear with a long list. Under the Network heading, choose AIRPORT. Scroll down and look at all the networks in your immediate area including yours. Notice the Channel different people are using. On #6 above, my Airport Express' channel was Automatic, so when I looked here, Channel 11 was chosen. The Apple rep told me to choose a different channel, and one that no one in my area had. Since my neighbors had channels 1, 3, and 6, I chose Channel 9. NOW PRESS UPDATE. Voila.
It's been a week. Now when I get home, the iPhone automatically switches to my home Wifi which is what it was supposed to do all along. My computer's Wifi works great for the first time in 6 months. If this helped you, punch in some points for me. Maybe I'll get to attend a Star Trek movie on the lawn of a cemetary.
Good luck!