If you look at your breadboard, there are letters and numbers. The letters are a..e, a divider and f..j.
The electrical connection are e.g. a1, b1, c1, d1 and e1 (as one group) and f1, g1, h1, i1 and j1 (as another group); there is no connection between a..e and f..j.
You have to move your wires closer to the ESP8266 module (at the other side of the divider).
And this is how you should have posted code ![]()
#include <ESP8266WiFi.h>
WiFiClient client;
WiFiServer server(80);
const char* ssid = "xx"; //WIFI SSID
const char* password = "xx"; //WIFI PASSWORD
String data ="";
int Relay1 = 12; //D6
int Relay2 = 16; //D0
int Relay3 = 4; //D2
int Relay4 = 5; //D1
void setup()
{
pinMode(Relay1, OUTPUT);
pinMode(Relay2, OUTPUT);
pinMode(Relay3, OUTPUT);
pinMode(Relay4, OUTPUT);
digitalWrite(Relay1,LOW);
digitalWrite(Relay2,LOW);
digitalWrite(Relay3,LOW);
digitalWrite(Relay4,LOW);
Serial.begin(115200);
connectWiFi();
server.begin();
}
void loop()
{
client = server.available();
if (!client) return;
data = checkClient ();
Serial.print(data);
if (data == "Relay1ON")
{
digitalWrite(Relay1,HIGH);
}
else if (data == "Relay1OFF")
{
digitalWrite(Relay1,LOW);
}
else if (data == "Relay2ON")
{
digitalWrite(Relay2,HIGH);
}
else if (data == "Relay2OFF")
{
digitalWrite(Relay2,LOW);
}
else if (data == "Relay3ON")
{
digitalWrite(Relay3,HIGH);
}
else if (data == "Relay3OFF")
{
digitalWrite(Relay3,LOW);
}
else if (data == "Relay4ON")
{
digitalWrite(Relay4,HIGH);
}
else if (data == "Relay4OFF")
{
digitalWrite(Relay4,LOW);
}
}
void connectWiFi()
{
Serial.println("Connecting to WIFI");
WiFi.begin(ssid, password);
while ((!(WiFi.status() == WL_CONNECTED)))
{
delay(300);
Serial.print("..");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("NodeMCU Local IP is : ");
Serial.print((WiFi.localIP()));
}
String checkClient (void)
{
while(!client.available()) delay(1);
String request = client.readStringUntil('\r');
request.remove(0, 5);
request.remove(request.length()-9,9);
return request;
}