Controling 5V relay with Wemos D1 R1 I would like to control a 5V relay with Wemos D1 R1 module through webserver. I'm using the following modules:

Tongling 5vdc Relay
Wemos D1 R1

I'm using the following schematic:

and here is the code I'm using:

#include &lt;ESP8266WiFi.h&gt;

const char* ssid = &quot;Myssidname&quot;;
const char* password = &quot;Myssidpass&quot;;

int ledPin = D3;
WiFiServer server(80);

void setup() {
 Serial.begin(9600);
 delay(10);


 pinMode(ledPin, OUTPUT);
 digitalWrite(ledPin, LOW);

 // Connect to WiFi network
 Serial.println();
 Serial.println();
 Serial.print(&quot;Connecting to &quot;);
 Serial.println(ssid);

 WiFi.begin(ssid, password);

 while (WiFi.status() != WL_CONNECTED) {
   delay(500);
   Serial.print(&quot;.&quot;);
 }
 Serial.println(&quot;&quot;);
 Serial.println(&quot;WiFi connected&quot;);

 // Start the server
 server.begin();
 Serial.println(&quot;Server started&quot;);

 // Print the IP address
 Serial.print(&quot;Use this URL : &quot;);
 Serial.print(&quot;http://&quot;);
 Serial.print(WiFi.localIP());
 Serial.println(&quot;/&quot;);

}

void loop() {
 // Check if a client has connected
 WiFiClient client = server.available();
 if (!client) {
   return;
 }

 // Wait until the client sends some data
 Serial.println(&quot;new client&quot;);
 while(!client.available()){
   delay(1);
 }

 // Read the first line of the request
 String request = client.readStringUntil('\r');
 Serial.println(request);
 client.flush();

 // Match the request

 int value = LOW;
 if (request.indexOf(&quot;/LED=ON&quot;) != -1) {
   digitalWrite(ledPin, HIGH);
   value = HIGH;
 }
 if (request.indexOf(&quot;/LED=OFF&quot;) != -1){
   digitalWrite(ledPin, LOW);
   value = LOW;
 }



 // Return the response
 client.println(&quot;HTTP/1.1 200 OK&quot;);
 client.println(&quot;Content-Type: text/html&quot;);
 client.println(&quot;&quot;); //  do not forget this one
 client.println(&quot;&lt;!DOCTYPE HTML&gt;&quot;);
 client.println(&quot;&lt;html&gt;&quot;);

 client.print(&quot;Led pin is now: &quot;);

 if(value == HIGH) {
   client.print(&quot;On&quot;);  
 } else {
   client.print(&quot;Off&quot;);
 }
 client.println(&quot;&lt;br&gt;&lt;br&gt;&quot;);
 client.println(&quot;Click &lt;a href=\&quot;/LED=ON\&quot;&gt;here&lt;/a&gt; Turn relay ON&lt;br&gt;&quot;);
 client.println(&quot;Click &lt;a href=\&quot;/LED=OFF\&quot;&gt;here&lt;/a&gt; Turn relay OFF&lt;br&gt;&quot;);
 client.println(&quot;&lt;/html&gt;&quot;);

 delay(1);
 Serial.println(&quot;Client disconnected&quot;);
 Serial.println(&quot;&quot;);

}


After uploading the code successfully and watching the monitor, the light gets turned on and I get the following message:
16:02:20.400 -&gt; WiFi connected
16:02:20.425 -&gt; Server started
16:02:20.479 -&gt; Use this URL : http://192.168.100.7/
16:02:41.680 -&gt; new client
16:02:41.680 -&gt; GET / HTTP/1.1
16:02:41.680 -&gt; Client disconnected

However, when I turn on or off the relay using the browser, nothing happens:
19:38:56.010 -&gt; new client
19:38:56.010 -&gt; GET /LED=ON HTTP/1.1
19:38:56.010 -&gt; Client disconnected
19:38:57.016 -&gt; new client
19:38:57.016 -&gt; GET /LED=OFF HTTP/1.1
19:38:57.063 -&gt; Client disconnected

However nothing happens to the light and relay doesn't click.
a few more notes:

I tried in upload the code with relay at high to disconnect the circuit but light is still on
Wemos Network name appears in my network list
It doesn't not respond to AT Commands
The issue lies with Wemos Module where it only outputs 3.3V which insufficient to 5V Relay so this can be solved by implementing 2N2222 Transistor as per schematic below.