matriX_1500
Junior Member level 1
Hi every One
I'm using NodeMCU board to communicate a laptop through WiFi. Basic communication is ok with a code like this:
But when i want to send data a Timer Tick, it seems the client couldn't connect to me.
I arduino serial monitor, i see only this:
40ms_Data A \r\n
40ms_Data A \r\n
....
So, could any one help me? maybe it a problem of WiFiClient deceleration in a non-forever loop (like example 1). But i have no idea to fix it.
Thanks
I'm using NodeMCU board to communicate a laptop through WiFi. Basic communication is ok with a code like this:
Code:
void loop (){
WiFiClient client = server.available();
if (client) {
while (client.connected()){
client.println(Data_mem[0]);
delay(2000);
}
client.stop(); // tarminates the connection with the client
}
}
But when i want to send data a Timer Tick, it seems the client couldn't connect to me.
Code:
void setup(){
....
//Initialize Ticker every 40ms
Data_Rec.attach_ms(40, 40ms_Data );
}
void 40ms_Data (){
WiFiClient client = server.available();
Serial.println("40ms_Data A");
if (client) {
Serial.println("40ms_Data B");
if (client .connected()){
Serial.println("40ms_Data C");
client.println(40ms_Data [0]);
}
else{
client.stop();
}
}
}
40ms_Data A \r\n
40ms_Data A \r\n
....
So, could any one help me? maybe it a problem of WiFiClient deceleration in a non-forever loop (like example 1). But i have no idea to fix it.
Thanks