Post topics, source code that relate to the Arduino Platform

User avatar
By gbafamily1
#66925 The function webSocket.broadcastTXT() sends the same data to all connected websocket clients.

In your code, data is sent to the websocket client specified by socketNumber but socketNumber is overwritten whenever a new client is connected so the old client stops receiving data.

String temp_str = String(temp_int);
webSocket.sendTXT(socketNumber, "wpMeter,Arduino," + temp_str + ",1");

Try the following.

webSocket.broadcastTXT("wpMeter,Arduino," + temp_str + ",1");

In addition, delay(200) as well as calls to blocking functions such as readStringUntil() will cause problems. loop() and all the functions it calls must avoid calls to delay() and blocking functions.