Board: ESP32 Dev Module C
Core Installation/update date: 10/jul/2018
IDE name: Arduino IDE 1.8.5 IDF from 10 Jul 2018
Flash Frequency: 40Mhz
Upload Speed: 115200
I have been battling to get my WiFi write speed above 8-12KB/sec. My read speed(Seems to recently have improved from also about 10KB/sec...) on same platform is +-180KB/sec which makes me very happy.
Basically the code looks like this.
void setup()
{
Serial.begin(115200);
int status = WiFi.status();
while ( status != WL_CONNECTED)
{
status = WiFi.begin("SSID", "password");
delay(10000);
}
Serial.print("WiFi Connected");
}
void loop()
{
WiFiClient dclient;
dclient.connect("server",port); //Connect to someone that will listen
dclient.setNoDelay(1);
unsigned char txBuf[1760]={ 0 };
while((WiFi.status() == WL_CONNECTED)&& (dclient.connected()) )
{
int txBytes = dclient.write(txBuf, sizeof(txBuf));
}
}
Some help/suggestions would be so much appreciated! My hair is running low :)
Regards
Gideon
When all is said and done, I need to transfer a big file from SD storage to a server via WiFI using FTP
You should maybe look into Async (check my repos) if you want high speeds. Currently Async is 20-40 times faster than the regular client.
Look promising:)
From a quick look at the ESP32 AsynchTCP class it would seem for sending data, its a simply changing dclient to be of class AsyncClient and not a WiFiClient? I am excited and am going to give it a try later tonight! And Probably some callbacks?
Is there a simple ESP32 send as fast you can example?
Battling a bit.
//Connect Wifi
void loop()
{
WiFiClient dclient;
dclient.connect("server",port); //Connect to someone that will listen
dclient.setNoDelay(1);
unsigned char txBuf[1760]={ 0 };
while((WiFi.status() == WL_CONNECTED)&& (dclient.connected()) )
{
int txBytes = dclient.write(txBuf, sizeof(txBuf));
Serial.printf("%d:%d\n", millis(), txBytes);
}
}
Output: Stable but slow at +-10KB/sec
29163:1360
29169:1360
29567:1360
29575:1360
29582:1360
29970:1360
29978:1360
29984:1360
30380:1360
Changing to what I think an AsyncClient dclient should look like things go badly..
AsyncClient dclient;
dclient.connect("server",port); //Connect to someone that will listen
dclient.setNoDelay(1);
unsigned char txBuf[1760]={ 0 };
while((WiFi.status() == WL_CONNECTED)&& (dclient.connected()) )
{
if (dclient.space() > (sizeof(txBuf)+200))
{
int txBytes = dclient.write((const char *)txBuf, noBytes);
Serial.printf("%d:%d\n", millis(), txBytes);
}
else
{
delay(50);
//yield();
}
}
The first few packets to arrive at the server side, but after that nothing is sent ever again...
177360:1360
177365:1360
177370:1360
177376:304
177382:0
177388:0
177393:0
177397:0
177402:0
177408:0
177412:0
177417:0
177423:0
177427:0
177432:0
177438:0
Any ideas what I am doing wrong?
Async is not a drop-in replacement. it works based on callbacks and is overall not easy to deal with. It requires a good understanding of how TCP works.
@HKGK any progress? I'm facing the same "slowness" . while uploading a file from SD.
This issue still seems unaddressed.
One would expect a lot more throughput on a dual core 240MHz controller than that.
The funny thing is that the client _can_ achieve higher rates (~20KB in ~0.4 sec) but not consistently (mostly ~20KB in ~3.3sec).
void serverStream() // callback for ESP32WebServer (stripped down)
{
WiFiClient client = server.client();
String response = "HTTP/1.1 200 OK\r\n";
response += "Content-Type: multipart/x-mixed-replace; boundary=frame\r\n\r\n";
server.sendContent(response);
while (client.connected())
{
// acquire data from camera
// place in 64K buffer
response = "--frame\r\n";
response += "Content-Type: image/jpeg\r\n\r\n";
server.sendContent(response);
if (client.connected()) {
client.write(buffer, len);
// delay(1); // optional for testing
}
}
}
I get better rates on a single core STM32F2 120MHz Particle Photon when sending the data in 1024 byte chunks.
None of the strategies I know from there as worked here so far.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Why is it unaddressed? I'd think this should be considered imporatant and not hope for this to vanish by itself ;-)
This stale issue has been automatically closed. Thank you for your contributions.
[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.
[STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions.
Hi,
I'm having the same problem here!
No problem at RX but when I want to TX something there is a lot of lag :/
I mentioned the problem here :
Hope I will find a solution with you all!
Experiencing the same thing, hoping for a solution too.
@HKGK @jeroenhouben @ScruffR @WavRX @alternadom Anyone was able to increase the speed? I would appreciate if you could share your experience in case you did.
I am having app. 30kB/sec read speed at the moment, though I need something like 1MB/sec.
Sadly I never got to the bottom of this and had to work with the poor throughput.
Please let me know if you have any luck
Gideon Krige
Somerset West
South Africa
From: RafigRzayev notifications@github.com
Sent: Thursday, 12 November 2020 15:18
To: espressif/arduino-esp32 arduino-esp32@noreply.github.com
Cc: Gideon J Krige gideonkrige@hotmail.com; Mention mention@noreply.github.com
Subject: Re: [espressif/arduino-esp32] WifiClient write is slow (#1648)
@HKGKhttps://github.com/HKGK @jeroenhoubenhttps://github.com/jeroenhouben @ScruffRhttps://github.com/ScruffR @WavRXhttps://github.com/WavRX @alternadomhttps://github.com/alternadom Anyone was able to increase the speed? I would appreciate if you could share your experience in case you did.
I am having app. 30kB/sec read speed at the moment, though I need something like 1MB/sec.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com/espressif/arduino-esp32/issues/1648#issuecomment-726071718, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AJVQO5R5DKPNNF64KGBAVODSPPOCNANCNFSM4FKDFE3Q.
@HKGK Hi, I was able to increase the speed 10 times. I will post instructions soon at https://github.com/espressif/arduino-esp32/issues/4529