Hi,
I'm able to successfully send data between ESP8266 and Python script. However, I'm trying following two things and have few questions.
setup()
{
connectWIFI(); // Working fine
delay(2000);
connecToServer(); // working fine
}
loop()
{
WiFiClient client;
if(client.connected())
{
client.println(55); // send some random data
}
else
{
digitalWrite(LED, HIGH);
}
}
In the above code, LED stays high meaning I'm not able to connect to server in the loop
Opposite to that, consider following code
setup()
{
connectWIFI(); // Working fine
delay(2000);
//connecToServer(); // working fine
}
loop()
{
WiFiClient client;
connecToServer();
client.println(55);
}
In the above code, I have to connect every loop to send data to server.
I'm not sure why do we have to connect everytime we want to send data? I also tried following loop() which is more or less same to above code. but that is not working too.
loop()
{
WiFiClient client;
connecToServer();
while(client.connected())
client.println(55);
}