Problem using ESP01 with relay v4 and webserver

I am using ESP01 with relay v4. After hours of test and debug I find out that the esp01 does not have energy to maintain webserver and manage relay at the same time. so, I find this creative workaround

any clue in order to discover the real cause and solution?

Without webserver, esp01 turn on and off the relay ok

When start webserver in setup function, the relay makes a very low sound, but it is not turn the mode of the relay.

This delay between close and restart server is necessary...maybe current in the circuit?
apkbark

void handleRoot() {
      flag = !flag;
      contador++;
    
      server.stop();
      server.close();
      delay(555);
    
      digitalWrite(RELAY, flag);
      digitalWrite(porta, flag);
    
      delay(555);
    
      server.on("/", handleRoot);
      server.begin();
      server.send(200, "text/html", "<h1>Ola, ESP01! contador = " + String(contador) + " </h1>");
    }

    void setup() {
      Serial.begin(115200);
    
      delay(1000);
    
      pinMode(RELAY, OUTPUT);
      pinMode(porta, OUTPUT);
      digitalWrite(RELAY, HIGH);
      digitalWrite(porta, HIGH);
    
      delay(1000);
    
      WiFi.begin(ssid, password);
    
    
      while (WiFi.status() != WL_CONNECTED) {
        delay(1000);
      }
    
      server.on("/", handleRoot);
      //server.on("/getparam", handleParam);
    
      server.begin();
    
      delay(333);
    }```

@realwilliamdavid
Are you supplying Vcc with 5V from a power supply?

are you using a ESP0101S-RELAY-MODULE
the example runs a webserver on the ESP-01S to switch relay On/OFF
post your code?
post a schematic of the wiring?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.