Hi,
I have written the code in arduino for making ESP32 DEVKITV1 a server.
There is some problem in receiving the data by using client.write() function.
It is getting halted for some seconds and then write the entire data received in those seconds suddenly.
Here i am attaching a dummy code in which i am writing count every second, it is also getting halted sometimes.
#include <WiFi.h>
#define SendKey 0 //Button to send data Flash BTN on NodeMCU
int port = 1111; //Port number
WiFiServer server(port);
//Server connect to WiFi Network
const char *ssid = "AKANSHA";
const char *password = "Akku@1234";
IPAddress staticIP(192,168,43,5);
IPAddress gateway(192,168,43,153);
IPAddress subnet(255, 255, 255, 0);
void setup()
{
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password); //Connect to wifi
// Wait for connection
Serial.println("Connecting to Wifi");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
delay(500);
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
server.begin();
Serial.print("Open Telnet and connect to IP:");
Serial.print(WiFi.localIP());
Serial.print(" on port ");
Serial.println(port);}
void loop()
{
WiFiClient client = server.available();
int count = 0;
int var = 0;
if (client) {
while(client.connected())
{while(client.available()>0)
{val = client.read();
if(val == '1')
{ while(client.connected())
{var = count+1;
client.write(var);
count++;
delay(1000);
}
}
}
}
client.stop();
Serial.println("Client disconnected");
}
}
Please help me n solving this random delay in between while writing data on client.
Thanks and regards
Akansha