-->
Page 1 of 1

esp8266 sending speed

PostPosted: Wed May 24, 2017 11:20 am
by Henry Yu
Hello !

I use esp8266 as TCP socket server, and Unity as client (Written in C#).

And I use esp8266 send a string that contain 70 bytes to Unity client.

But it seems that it takes 3.3 sec to receive 100 times this string, I expected a higher speed.

So what sending speed do esp8266 have? Is there anyway to get higher?

Here is my Arduino code :

Code: Select all#include "I2Cdev.h"
#include <ESP8266wifi.h>
#define DEBUG false

void setup()
{
  Serial.begin(115200);
  Serial1.begin(115200); // your esp's baud rate might be different
  sendData("AT+RST\r\n", 2000, DEBUG); // reset module
  sendData("AT+CWMODE=2\r\n", 1000, DEBUG); // configure as access point
  sendData("AT+CIFSR\r\n", 1000, DEBUG); // get ip address
  sendData("AT+CIPMUX=1\r\n", 1000, DEBUG); // configure for multiple connections
  sendData("AT+CIPSERVER=1,80\r\n", 1000, DEBUG); // turn on server on port 80
}

void loop()
{
 
  if (Serial1.available()) // check if the esp is sending a message
  {
    Data="+0.1234+0.1234+0.1234+0.1234+0.1234+0.1234+0.1234+0.1234+0.1234+0.1234";
    String cipSend = "AT+CIPSEND=";
    cipSend += connectionId;
    cipSend += ",";
    cipSend += Data.length();
    cipSend += "\r\n";
    sendData(cipSend , 3, DEBUG);
    sendData(Data, 3, DEBUG);
    Data = "";
  }
  else
  {
    Data = "";
  }
}


String sendData(String command, const int timeout, boolean debug)
{
  String response = "";

  Serial1.print(command); // send the read character to the esp8266

  long int time = millis();

  while ( (time + timeout) > millis())
  {
    while (Serial1.available())
    {
      // The esp has data so display its output to the serial window
      char c = Serial1.read(); // read the next character.
      response += c;
      //Serial.println("Forming Char");
    }
  }

  if (debug)
  {
    Serial.print(response);
  }

  return response;
}