Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Websockets stuttering on Arduino Nano 33 IOT When writing every 16 ms. #95

Open
AdamMarciniak opened this issue Dec 5, 2020 · 0 comments

Comments

@AdamMarciniak
Copy link

AdamMarciniak commented Dec 5, 2020

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");
}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant