Hello,
I developed a custom board for a ESP32 and I'm getting problems with the brownout detector when I try to work with the WIFI.
I know it's a matter of hardware but I can't get rid of the problem, so in the meanwhile I find the solution with different capacitors and so on, I'd like to know if there is any way to minimize the problem by coding in some specific way or if there are any tips I should take into consideration (i.e. changing speed of the processor or whatever)
What I try to do is to start the WIFI in WIFI_MODE_APSTA both AP and WIFI comnnected device.
The part of my code related to WIFI is as follows:
class CaptiveRequestHandler : public AsyncWebHandler {
public:
CaptiveRequestHandler() {}
virtual ~CaptiveRequestHandler() {}
bool canHandle(AsyncWebServerRequest *request){
//request->addInterestingHeader("ANY");
return true;
}
void handleRequest(AsyncWebServerRequest *request) {
request->send(SPIFFS, "/index.html", "text/html", false, processor);
}
};
begin_wifi()
{
WiFi.mode(WIFI_MODE_APSTA);
// Access Point
WiFi.softAP("XXXX", "12345678");
dnsServer.start(53, "*", WiFi.softAPIP());
server.addHandler(new CaptiveRequestHandler()).setFilter(ON_AP_FILTER);//only when requested from AP
Serial.println("Building up Access Point...");
IPAddress IP = WiFi.softAPIP();
Serial.print("AP IP address: ");
Serial.println(IP);
// WiFi
if(_ssid=="")
{
Serial.println("Undefined SSID. Not possible to connect to WIFI");
return false;
}
else
{
WiFi.begin(_ssid.c_str(), _pass.c_str());
Serial.println("Connecting to WiFi...");
unsigned long current_time = millis();
previous_time = current_time;
while(WiFi.status() != WL_CONNECTED)
{
current_time = millis();
if (current_time - previous_time >= Delay)
{
Serial.println("Failed to connect.");
return false;
}
}
}
}