I kept having trouble getting my ESP8266 to consistently connect to WiFi, so I wrote a script that checks if there's a connection, and also stores multiple SSID's to try (so when I change locations, it just connects automatically).
If it is helpful to anyone, I put it up here: https://medium.com/@sungkhum/robust-wif ... 4208ecbd27