I'm using an Arduino Nano 33 IOT with the simple websocket example. I've modified it to send a message every 16ms (so 60fps) and I do get the messages on the other side and in order but they come more in batches rather than smoothly. I am graphing these values and they stutter on the other end. I know it's not my server, my internet connection or router etc since it works smoothly on the ESP32 board I've got with another library.
You can try it yourself and see the effects by sending a websocket message like so "1,234,145,664" every 16ms to this address I've put up and port:
server: "adam.teaches.engineering"
path: "/capstone/ws?clientId=1"
port: 80
You can visit the graph live output site to see the stuttering at : "http://adam.teaches.engineering/capstone"
Here is the code I'm using:
`/*
Simple WebSocket client for ArduinoHttpClient library
Connects to the WebSocket server, and sends a hello
message every 5 seconds
created 28 Jun 2016
by Sandeep Mistry
modified 22 Jan 2019
by Tom Igoe
this example is in the public domain
*/
#include <ArduinoHttpClient.h>
#include <WiFiNINA.h>
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
/////// Wifi Settings ///////
char ssid[] = "HIDDEN";
char pass[] = "HIDDEN";
char serverAddress[] = "adam.teaches.engineering"; // server address
int port = 80;
WiFiClient wifi;
WebSocketClient client = WebSocketClient(wifi, serverAddress, port);
int status = WL_IDLE_STATUS;
int count = 0;
void setup() {
Serial.begin(9600);
while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to Network named: ");
Serial.println(ssid); // print the network name (SSID);
// Connect to WPA/WPA2 network:
status = WiFi.begin(ssid, pass);
}
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print your WiFi shield's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
client.begin("/capstone/ws?clientId=1");
}
void loop() {
while (client.connected()) {
client.beginMessage(TYPE_TEXT);
client.print("1,234,444,555,666");
client.endMessage();
delay(16);
}
Serial.println("disconnected");
}`
I'm using an Arduino Nano 33 IOT with the simple websocket example. I've modified it to send a message every 16ms (so 60fps) and I do get the messages on the other side and in order but they come more in batches rather than smoothly. I am graphing these values and they stutter on the other end. I know it's not my server, my internet connection or router etc since it works smoothly on the ESP32 board I've got with another library.
You can try it yourself and see the effects by sending a websocket message like so "1,234,145,664" every 16ms to this address I've put up and port: server: "adam.teaches.engineering" path: "/capstone/ws?clientId=1" port: 80 You can visit the graph live output site to see the stuttering at : "http://adam.teaches.engineering/capstone"
Here is the code I'm using: