Hi, I found out that my ESP8266 keep disconnected from Wifi after a few minutes can reconnect back. This only happen when I power the ESP8266 from an external power source but did not happen when I power it from the microUSB port. I think it is related to deep sleep mode?
I tried using command WiFi.setSleepMode(WIFI_NONE_SLEEP); which I found out from other forum but it just keep happening or am I using it wrongly?
How can I keep my ESP8266 connected to WiFi all the time as I will have to control and observe my relay on Blynk apps?
Here is my code where I put WiFi.setSleepMode(WIFI_NONE_SLEEP);
Please share some details on this power source. The problem may be there, because when using WiFi, power consumption of the ESP8266 rises sharply. Your power supply may not keep up. Especially notorious are small power supplies based on a linear regulator with insufficient cooling; they heat up, switch off in thermal protection causing the microcontroller to switch off, then the regulator cools down a bit and the cycle repeats.
Which connects to a 12V adapter? That's exactly the kind of problem I described.
Get yourself a better power supply, this one sucks.
Edit: it's not so much that it sucks, but it just isn't up to the task of powering somewhat larger devices. This module houses two AMS1117 regulators, which are nice little devices - but emphasis on 'little'. If you feed them 12V in and ask them to give 5V out, and then start drawing 500mA (which an ESP processor may do during WiFi), the 1117 is going to dissipate 12 - 5 = 7 * .5 = 3.5W. It'll get hot! Even if power consumption remains at the 170mA level that I think is specified for the ESP8266 WiFi, it's still 7 * .15 = 1.05W which is way above the limit of an SMD AMS1117 without additional cooling measures.
If you have a 5V supply going into the MB102, why even have the MB102 in the first place...?
What you need is either a buck step-down converter to take the 12V (or whatever it is) from your adapter down to 5V, or get yourself a little 5V power supply that plugs directly into a wall socket...like a USB charger. They're omnipresent and often rated up to 2A or thereabouts; plenty for an ESP8266 with a handful of sensors attached to it, for instance.