-->
Page 1 of 1

esp8266 Telnet slow performance

PostPosted: Thu Dec 10, 2015 11:41 am
by picstart
The project involves a GY-87 navigation pcb MPU6050 HMC5883 and a BMP180 Arduino IDE 1.6.5
It is working ( no FIFO overflows) with an esp8266 115200 Serial >usb>PC serial Comm port connection to a modified Processing teapot app running on a Fast Windows PC.
Mod to teapot code is small it just allows for a heading from magnetometer to be added to the packet and be displayed.
The below code uses telnet. The esp8266 is the server and the teapot app the client.
If this worked well it would allow for a wireless connection.
Well the telnet code works but every other reading from the MPU6050 gets a MPU6050 FIFO overflow error. It makes the teapot animation a bit jerky.
The issue appears to be a speed bottleneck with the esp8266 WIFI.
Can anyone confirm that the esp8266 can't get packets out quickly?
The code below allows for more than one teapot client to receive the data max clients is 3 but the issue occurs with a single client.
The serial print is the the Arduino IDE console and it makes no diference to the issue if it is commented out.
[code]
for(int i = 0; i < MAX_SRV_CLIENTS; i++)
{
if (serverClients[i] && serverClients[i].connected())
{
size_t len=18;
serverClients[i].write((char*) &teapotPacket, len);
//// needs the datastructure and its length (char*) defines the pointer's type for idexing
//// and &teapotPacket is the address
Serial.print("\nClient=");
Serial.print(i);
Serial.print("packet=");
Serial.print(teapotPacket[15]);
}
}


//Serial.write(teapotPacket, 18);
[/code]

Re: esp8266 Telnet slow performance

PostPosted: Sat Dec 12, 2015 3:06 pm
by picstart
The code below is in 2 chunks.. 1st .arduino 1de 1.6.5 for the esp8266 and 2nd Processing
It sends 100 18 char packets and takes over 10 secs to do it......180 chars per sec or 1800 baud
I must be doing something wrong for it to be this slow.
Anyone have advice?

[code]
/*
WiFiTelnetToSerial - Example Transparent UART to Telnet Server for esp8266

Copyright (c) 2015 Hristo Gochkov. All rights reserved.
This file is part of the ESP8266WiFi library for Arduino environment.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <ESP8266WiFi.h>
//#include <WiFi.h>
//how many clients should be able to telnet to this ESP8266
extern "C" {
#include "user_interface.h"

}
#define MAX_SRV_CLIENTS 1
const char* ssid = "xxxxxxxx";
const char* password = "xxxxxxx";

WiFiServer server(23);
WiFiClient serverClients[MAX_SRV_CLIENTS];
uint16_t posts=0;
void setup() {
Serial.begin(115200);

WiFi.begin(ssid, password);
// WiFi.sta.setip(ip="33.42.0.20",netmask="255.255.255.0",gateway="33.42.0.254")
Serial.print("\nConnecting to "); Serial1.println(ssid);
uint8_t i = 0;
while (WiFi.status() != WL_CONNECTED && i++ < 20) delay(500);
if(i == 21)
{
Serial.print("Could not connect to"); Serial.println(ssid);
while(1) delay(500);
}
//start UART and the server

server.begin();
server.setNoDelay(true);

Serial.print("Ready! Use 'telnet ");
Serial.print(WiFi.localIP());
Serial.println(" 23' to connect");
}

void loop() {
uint8_t i;
//check if there are any new clients
if (server.hasClient()){
for(i = 0; i < MAX_SRV_CLIENTS; i++){
//find free/disconnected spot
if (!serverClients[i] || !serverClients[i].connected()){
if(serverClients[i]) serverClients[i].stop();
serverClients[i] = server.available();
Serial.print("New client: "); Serial1.print(i);
continue;
}
}
//no free/disconnected spot so reject
WiFiClient serverClient = server.available();
serverClient.stop();
}



posts++;
size_t len = 18;
char sbuf[18]="abcdefghijklmno\n\r";
char tbuf[18]="100 sent \n\r";
for(i = 0; i < MAX_SRV_CLIENTS; i++)
{
if (serverClients[i] && serverClients[i].connected())
{
if (posts<100)
{
serverClients[i].write((char*) &sbuf, len);

//// needs the datastructure and its length (char*) defines the pointer's type for idexing
//// and &sbuf is the address
}
else
{
serverClients[i].write((char*) &tbuf, len);

//// needs the datastructure and its length (char*) defines the pointer's type for idexing
//// and &sbuf is the address
}
}
}

if( posts==100)
{posts=0;
delay(5000);
}
}[/code]

[code]import processing.net.*;

Client myClient;
String dataIn;

void setup() {
size(300, 300);
background(0); // black background
textSize(30);
// Connect to the local machine at port 21 Telnet.
// This example will not run if you haven't
// previously started a server on this port.
myClient = new Client(this, "33.42.0.109", 23);
}

void draw()
{
//// somewhat like loop it will keep us alive allowing the isr on client event interrupt to do the work

}
// ClientEvent message is generated when the server
// sends data to an existing client.
void clientEvent(Client myClient)
{
while (myClient.available() > 0)
{
dataIn = myClient.readString();
print (dataIn);
}


}[/code]