Please slove this error

Arduino: 1.8.15 (Windows 7), Board: "Generic ESP8266 Module, 80 MHz, 40MHz, DOUT, 115200, 512K (64K SPIFFS), nodemcu, Disabled, None"

C:\Users\home\Documents\Arduino\node\node.ino: In function 'void loop()':

node:58:30: error: expected primary-expression before 'available'

WiFiClient client = Server available();

                          ^

exit status 1

expected primary-expression before 'available'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

A dot?

Server.available();

I suspect you need to check your cut & paste.
The code snippet you posted makes no sense

@sahil01, your topic has been moved to a more suitable location on the forum.

Nobody will be able to solve your problem if you don't post your code.

Please spend some time reading How to get the best out of this forum and next post your code using code tags as described in the link.

dot - not only.

i will send a code please correct it please #include <Blynk.h>
#include<ESP8266WiFi.h>

const char* ssid = "sahil"; // SSID i.e. Service Set Identifier is the name of your WIFI
const char* password = "12345678"; // Your Wifi password, in case you have open network comment the whole statement.

int R1 = 1; // GPIO13 or for NodeMCU you can directly write D7
int R2 = 2;
int R3 = 3;
int R4 = 4;

WiFiClient client;
void setup() {
Serial.begin(115200);
delay(10);

pinMode(R1, OUTPUT);
pinMode(R2, OUTPUT);
pinMode(R3, OUTPUT);
pinMode(R4, OUTPUT);

digitalWrite(R1, LOW);
digitalWrite(R2, LOW);
digitalWrite(R3, LOW);
digitalWrite(R4, LOW);

{
// Connect to WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);

delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");

// Start the server
Serial.begin(9600);
Serial.println("Server started");

// Print the IP address
Serial.print("Use this URL to connect: ");
Serial.print("http://");

Serial.println("/");

}

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

// Wait until the client sends some data
Serial.println("new client");
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

if (request.indexOf("/Relay1On") != -1) {
digitalWrite(R1, HIGH);

client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("");
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("Relay 1 is ON");
client.println("</html>");
client.stop();
delay(1);

}
if (request.indexOf("/Relay1Off") != -1) {
digitalWrite(R1, LOW);

client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("");
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("Relay 1 is OFF");
client.println("</html>");
client.stop();
delay(1);

}

if (request.indexOf("/Relay2On") != -1) {
digitalWrite(R2, HIGH);

client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("");
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("Relay 2 is ON");
client.println("</html>");
client.stop();
delay(1);

}
if (request.indexOf("/Relay2Off") != -1) {
digitalWrite(R2, LOW);

client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("");
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("Relay 2 is OFF");
client.println("</html>");
client.stop();
delay(1);

}

if (request.indexOf("/Relay3On") != -1) {
digitalWrite(R3, HIGH);

client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("");
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("Relay 3 is ON");
client.println("</html>");
client.stop();
delay(1);

}
if (request.indexOf("/Relay3Off") != -1) {
digitalWrite(R3, LOW);

client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("");
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("Relay 3 is OFF");
client.println("</html>");
client.stop();
delay(1);

}

if (request.indexOf("/Relay4On") != -1) {
digitalWrite(R4, HIGH);

client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("");
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("Relay 4 is ON");
client.println("</html>");
client.stop();
delay(1);

}
if (request.indexOf("/Relay4Off") != -1) {
digitalWrite(R4, LOW);

client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("");
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("Relay 4 is OFF");
client.println("</html>");
client.stop();
delay(1);

}

}

#include <Blynk.h>
#include<ESP8266WiFi.h>

const char* ssid = "sahil"; // SSID i.e. Service Set Identifier is the name of your WIFI
const char* password = "12345678"; // Your Wifi password, in case you have open network comment the whole statement.

int R1 = 1; // GPIO13 or for NodeMCU you can directly write D7
int R2 = 2;
int R3 = 3;
int R4 = 4;

WiFiClient client;
void setup() {
Serial.begin(115200);
delay(10);

pinMode(R1, OUTPUT);
pinMode(R2, OUTPUT);
pinMode(R3, OUTPUT);
pinMode(R4, OUTPUT);

digitalWrite(R1, LOW);
digitalWrite(R2, LOW);
digitalWrite(R3, LOW);
digitalWrite(R4, LOW);

{
// Connect to WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);

delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");

// Start the server
Serial.begin(9600);
Serial.println("Server started");

// Print the IP address
Serial.print("Use this URL to connect: ");
Serial.print("http://");

Serial.println("/");

}

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

// Wait until the client sends some data
Serial.println("new client");
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

if (request.indexOf("/Relay1On") != -1) {
digitalWrite(R1, HIGH);

client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("");
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("Relay 1 is ON");
client.println("</html>");
client.stop();
delay(1);

}
if (request.indexOf("/Relay1Off") != -1) {
digitalWrite(R1, LOW);

client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("");
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("Relay 1 is OFF");
client.println("</html>");
client.stop();
delay(1);

}

if (request.indexOf("/Relay2On") != -1) {
digitalWrite(R2, HIGH);

client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("");
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("Relay 2 is ON");
client.println("</html>");
client.stop();
delay(1);

}
if (request.indexOf("/Relay2Off") != -1) {
digitalWrite(R2, LOW);

client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("");
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("Relay 2 is OFF");
client.println("</html>");
client.stop();
delay(1);

}

if (request.indexOf("/Relay3On") != -1) {
digitalWrite(R3, HIGH);

client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("");
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("Relay 3 is ON");
client.println("</html>");
client.stop();
delay(1);

}
if (request.indexOf("/Relay3Off") != -1) {
digitalWrite(R3, LOW);

client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("");
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("Relay 3 is OFF");
client.println("</html>");
client.stop();
delay(1);

}

if (request.indexOf("/Relay4On") != -1) {
digitalWrite(R4, HIGH);

client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("");
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("Relay 4 is ON");
client.println("</html>");
client.stop();
delay(1);

}
if (request.indexOf("/Relay4Off") != -1) {
digitalWrite(R4, LOW);

client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("");
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("Relay 4 is OFF");
client.println("</html>");
client.stop();
delay(1);

}

}
please correct the code and send to me i am your student

Again, please read the link that I gave you.

Next edit your post, select all code and click </> above the editor text box and save your post.

1 Like
#include <Blynk.h>
#include<ESP8266WiFi.h>


const char* ssid = "sahil"; // SSID i.e. Service Set Identifier is the name of your WIFI
const char* password = "12345678"; // Your Wifi password, in case you have open network comment the whole statement.

int R1 = 1; // GPIO13 or for NodeMCU you can directly write D7
int R2 = 2;
int R3 = 3;
int R4 = 4;
  WiFiClient client;
void setup() {
  Serial.begin(115200);
  delay(10);

  pinMode(R1, OUTPUT);
  pinMode(R2, OUTPUT);
  pinMode(R3, OUTPUT);
  pinMode(R4, OUTPUT);

  digitalWrite(R1, LOW);
  digitalWrite(R2, LOW);
  digitalWrite(R3, LOW);
  digitalWrite(R4, LOW);



{
  // Connect to WiFi network
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);



  delay(500);
  Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");

// Start the server
Serial.begin(9600);
Serial.println("Server started");

// Print the IP address
Serial.print("Use this URL to connect: ");
Serial.print("http://");

Serial.println("/");

}

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

  // Wait until the client sends some data
  Serial.println("new client");
  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


  if (request.indexOf("/Relay1On") != -1)  {
    digitalWrite(R1, HIGH);

    client.println("HTTP/1.1 200 OK");
    client.println("Content-Type: text/html");
    client.println("");
    client.println("<!DOCTYPE HTML>");
    client.println("<html>");
    client.println("Relay 1 is ON");
    client.println("</html>");
    client.stop();
    delay(1);
  }
  if (request.indexOf("/Relay1Off") != -1)  {
    digitalWrite(R1, LOW);

    client.println("HTTP/1.1 200 OK");
    client.println("Content-Type: text/html");
    client.println("");
    client.println("<!DOCTYPE HTML>");
    client.println("<html>");
    client.println("Relay 1 is OFF");
    client.println("</html>");
    client.stop();
    delay(1);
  }


  if (request.indexOf("/Relay2On") != -1)  {
    digitalWrite(R2, HIGH);

    client.println("HTTP/1.1 200 OK");
    client.println("Content-Type: text/html");
    client.println("");
    client.println("<!DOCTYPE HTML>");
    client.println("<html>");
    client.println("Relay 2 is ON");
    client.println("</html>");
    client.stop();
    delay(1);

  }
  if (request.indexOf("/Relay2Off") != -1)  {
    digitalWrite(R2, LOW);

    client.println("HTTP/1.1 200 OK");
    client.println("Content-Type: text/html");
    client.println("");
    client.println("<!DOCTYPE HTML>");
    client.println("<html>");
    client.println("Relay 2 is OFF");
    client.println("</html>");
    client.stop();
    delay(1);
  }


  if (request.indexOf("/Relay3On") != -1)  {
    digitalWrite(R3, HIGH);

    client.println("HTTP/1.1 200 OK");
    client.println("Content-Type: text/html");
    client.println("");
    client.println("<!DOCTYPE HTML>");
    client.println("<html>");
    client.println("Relay 3 is ON");
    client.println("</html>");
    client.stop();
    delay(1);
  }
  if (request.indexOf("/Relay3Off") != -1)  {
    digitalWrite(R3, LOW);

    client.println("HTTP/1.1 200 OK");
    client.println("Content-Type: text/html");
    client.println("");
    client.println("<!DOCTYPE HTML>");
    client.println("<html>");
    client.println("Relay 3 is OFF");
    client.println("</html>");
    client.stop();
    delay(1);
  }

  if (request.indexOf("/Relay4On") != -1)  {
    digitalWrite(R4, HIGH);

    client.println("HTTP/1.1 200 OK");
    client.println("Content-Type: text/html");
    client.println("");
    client.println("<!DOCTYPE HTML>");
    client.println("<html>");
    client.println("Relay 4 is ON");
    client.println("</html>");
    client.stop();
    delay(1);
  }
  if (request.indexOf("/Relay4Off") != -1)  {
    digitalWrite(R4, LOW);

    client.println("HTTP/1.1 200 OK");
    client.println("Content-Type: text/html");
    client.println("");
    client.println("<!DOCTYPE HTML>");
    client.println("<html>");
    client.println("Relay 4 is OFF");
    client.println("</html>");
    client.stop();
    delay(1);
  }

}

:pray: you are great please correct the code

#include <Blynk.h>
#include<ESP8266WiFi.h>

const char* ssid = "sahil"; // SSID i.e. Service Set Identifier is the name of your WIFI
const char* password = "12345678"; // Your Wifi password, in case you have open network comment the whole statement.

int R1 = 1; // GPIO13 or for NodeMCU you can directly write D7
int R2 = 2;
int R3 = 3;
int R4 = 4;

WiFiClient client;
void setup() {
Serial.begin(115200);
delay(10);

pinMode(R1, OUTPUT);
pinMode(R2, OUTPUT);
pinMode(R3, OUTPUT);
pinMode(R4, OUTPUT);

digitalWrite(R1, LOW);
digitalWrite(R2, LOW);
digitalWrite(R3, LOW);
digitalWrite(R4, LOW);

{
// Connect to WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);

delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");

// Start the server
Serial.begin(9600);
Serial.println("Server started");

// Print the IP address
Serial.print("Use this URL to connect: ");
Serial.print("http://");

Serial.println("/");

}

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

// Wait until the client sends some data
Serial.println("new client");
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

if (request.indexOf("/Relay1On") != -1) {
digitalWrite(R1, HIGH);

client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("");
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("Relay 1 is ON");
client.println("</html>");
client.stop();
delay(1);

}
if (request.indexOf("/Relay1Off") != -1) {
digitalWrite(R1, LOW);

client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("");
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("Relay 1 is OFF");
client.println("</html>");
client.stop();
delay(1);

}

if (request.indexOf("/Relay2On") != -1) {
digitalWrite(R2, HIGH);

client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("");
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("Relay 2 is ON");
client.println("</html>");
client.stop();
delay(1);

}
if (request.indexOf("/Relay2Off") != -1) {
digitalWrite(R2, LOW);

client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("");
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("Relay 2 is OFF");
client.println("</html>");
client.stop();
delay(1);

}

if (request.indexOf("/Relay3On") != -1) {
digitalWrite(R3, HIGH);

client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("");
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("Relay 3 is ON");
client.println("</html>");
client.stop();
delay(1);

}
if (request.indexOf("/Relay3Off") != -1) {
digitalWrite(R3, LOW);

client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("");
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("Relay 3 is OFF");
client.println("</html>");
client.stop();
delay(1);

}

if (request.indexOf("/Relay4On") != -1) {
digitalWrite(R4, HIGH);

client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("");
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("Relay 4 is ON");
client.println("</html>");
client.stop();
delay(1);

}
if (request.indexOf("/Relay4Off") != -1) {
digitalWrite(R4, LOW);

client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("");
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("Relay 4 is OFF");
client.println("</html>");
client.stop();
delay(1);

}

}

I've merged your cross-posts @sahil01 .

Cross-posting is against the rules of the forum. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes (or more) writing a detailed answer on this topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting can result in a suspension from the forum.

In the future, please take some time to pick the forum board that best suits the topic of your question and then only post once to that forum board. This is basic forum etiquette, as explained in the "How to get the best out of this forum" guide you will find at the top of every forum category. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

the error: client = Server available();

I suggest you use this code to set up the WiFi communication


void setup() {
  Serial.begin(115200);         // Start the Serial communication to send messages to the computer
  delay(10);
  Serial.println('\n');
  
  WiFi.begin(ssid, password);             // Connect to the network
  Serial.print("Connecting to ");
  Serial.print(ssid); Serial.println(" ...");

  int i = 0;
  while (WiFi.status() != WL_CONNECTED) { // Wait for the Wi-Fi to connect
    delay(1000);
    Serial.print(++i); Serial.print(' ');
  }

  Serial.println('\n');
  Serial.println("Connection established!");  
  Serial.print("IP address:\t");
  Serial.println(WiFi.localIP());         // Send the IP address of the ESP8266 to the computer
}

This part of your setup is all wrong