Is your device having a brownout?
Frequently the power consumption of the device will momentarily increase when it needs to transmit data over WiFi. If the power source is not capable of supplying the required power, a brownout may occur. I've had this happen to me with several ESP8266 devices.
Some things to try:
- Connect your device using an ethernet cable (if that is an option) and power it by external power (as opposed to battery power) and see if it reliably retrieves data
- If (1) works, then power it by new battery/freshly charged battery and ensure it works reliably
- If (2) works, then switch to wifi at a spot that has strong Wifi signal and ensure it works reliably
- If (3) works, deploy device in field