I'm doing some experiment on my new board Arduino Giga and the Display shield, and I wanted to visualize, on the TFT, the image from a camera available as snapshot 320x240. (See esp32-cam, from my Intercom project).
On the M5stack, I managed to get around 4 frame per seconds, while on the Arduino Giga, having a faster CPU, I was getting a frame every 2 seconds.
OK, there are big difference in the Hardware and in the libraries, however I was not expecting so big changes.
I did my tests putting both device on the same network, very closer, and the payload was around 8KBThis is the code of that part.
void get_data() {
uint32_t initime = millis();
uint32_t time1, time2, time3, fintime;
Serial.println("making GET request");
httpclient.get("/jpg");
httpclient.connectionKeepAlive();
time1 = millis();
// read the status code and body of the response
int statusCode = httpclient.responseStatusCode();
time2 = millis();
Serial.print("Status Code:");
Serial.println(statusCode);
buff_str = httpclient.responseBody();
fintime = millis();
Serial.println("=====================================");
Serial.println("Total download time was : ");
Serial.print("Get: ");
Serial.println(time1 - initime);
Serial.print("Status: ");
Serial.println(time2 - time1);
Serial.print("Body: ");
Serial.println(fintime - time2);
Serial.print("Total: ");
Serial.println(fintime - initime);
Serial.println("=====================================");
httpclient.completed();
copy_data();
len = httpclient.contentLength();
}
According to the output:
20:26:22.757 -> making GET request
20:26:23.843 -> Status Code:200
20:26:24.007 -> =====================================
20:26:24.007 -> Total download time was :
20:26:24.007 -> Get: 81
20:26:24.007 -> Status: 999 // <<<<<<<<< Slowest part
20:26:24.007 -> Body: 161
20:26:24.007 -> Total: 1241
20:26:24.007 -> =====================================
Most of the time is spent on this instruction:
int statusCode = httpclient.responseStatusCode();
But, if I try to remove that line, the delay get moved to
buff_str = httpclient.responseBody();
Indicating the client is not yet ready before 1 second to deliver the payload.A good hint comes from this issue:
https://github.com/arduino-libraries/ArduinoHttpClient/issues/38
pointing to a very long delay, awaiting the page to be available:Following that instruction, I changed line 343 on file libraries/ArduinoHttpClient/src/HttpClient.hfrom
static const int kHttpWaitForDataDelay = 1000;
to
static const int kHttpWaitForDataDelay = 10;
And Magically the performance boosted, requiring 300ms for the full download
20:23:37.804 -> making GET request
20:23:38.001 -> Status Code:200
20:23:38.165 -> =====================================
20:23:38.165 -> Total download time was :
20:23:38.165 -> Get: 68
20:23:38.165 -> Status: 130
20:23:38.165 -> Body: 161
20:23:38.165 -> Total: 359
20:23:38.165 -> =====================================
It can be better, probably requires some more changes, but is still good, considering the web server is an esp32-cam, which can contribute to this download time
Comments