Hello,
it seems to me that downloading file ~10MB takes pretty long time?
Are there any settings I should be aware of, or it is just platform limit.
Same file over same router is downloaded almost instantly on my PC.
BR!
What download speeds are available on WiFi?
Re: What download speeds are available on WiFi?
You can expect to get around 20Mbit/s for TCP, provided that you can process the received data fast enough: https://docs.espressif.com/projects/esp ... throughput
If you are saving the file to a filesystem on the ESP32, then the download speed will likely be limited by the speed of writing to Flash, and not by Wi-Fi.
If you are saving the file to a filesystem on the ESP32, then the download speed will likely be limited by the speed of writing to Flash, and not by Wi-Fi.
Re: What download speeds are available on WiFi?
Thank you for helping out!
Ok, so I am not even close to achieve this kind of speeds with example code.
On my PC it is downloaded in a sec. Both ESP32 and PC are connected over WiFi.
I have modifed log to get output and it looks like this:
Code looks like this:
Ok, so I am not even close to achieve this kind of speeds with example code.
On my PC it is downloaded in a sec. Both ESP32 and PC are connected over WiFi.
I have modifed log to get output and it looks like this:
So looking at this log it time of 91.69 sec doesn't even get close for this size of content ~1.2 MB.E (7565) HTTP_CLIENT: Connected to AP, begin http example
E (7925) HTTP_CLIENT: HTTP_EVENT_ON_CONNECTED
E (8335) HTTP_CLIENT: HTTP_EVENT_ON_HEADER, key=Date, value=Sat, 23 Mar 2019 00:11:46 GMT
E (8335) HTTP_CLIENT: HTTP_EVENT_ON_HEADER, key=Server, value=Apache/2.2.3 (Red Hat)
E (8345) HTTP_CLIENT: HTTP_EVENT_ON_HEADER, key=Last-Modified, value=Tue, 03 Aug 2004 06:17:00 GMT
E (8355) HTTP_CLIENT: HTTP_EVENT_ON_HEADER, key=ETag, value="a4cb91-138800-dd822f00"
E (8365) HTTP_CLIENT: HTTP_EVENT_ON_HEADER, key=Accept-Ranges, value=bytes
E (8375) HTTP_CLIENT: HTTP_EVENT_ON_HEADER, key=Content-Length, value=1280000
E (8375) HTTP_CLIENT: HTTP_EVENT_ON_HEADER, key=Connection, value=close
E (8385) HTTP_CLIENT: HTTP_EVENT_ON_HEADER, key=Content-Type, value=application/x-gzip
E (100085) HTTP_CLIENT: HTTP_EVENT_ON_FINISH
E (100085) HTTP_CLIENT: TIME OF EXECUTION: 91.69
E (100085) HTTP_CLIENT: HTTP_EVENT_DISCONNECTED
E (100085) HTTP_CLIENT: HTTP_EVENT_DISCONNECTED
E (100095) HTTP_CLIENT: Finish http example
Code looks like this:
Code: Select all
/* ESP HTTP Client Example
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#define LOG_LOCAL_LEVEL ESP_LOG_ERROR
//#define __SAVE_FILE_TO_SDCARD__
#include <string.h>
#include <stdlib.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"
#include "esp_system.h"
#include "nvs_flash.h"
#include "app_wifi.h"
#include "esp_http_client.h"
//#define MAX_HTTP_RECV_BUFFER 512
#define MAX_HTTP_RECV_BUFFER 1024
static const char *TAG = "HTTP_CLIENT";
// ------------------ GLOBAL VARS -----------------------------
FILE *fp=NULL;
uint32_t filesize_count=5245254;
uint32_t m_time_start=0;
uint32_t m_time_end=0;
// ------------------ GLOBAL VARS -----------------------------
/* Root cert for howsmyssl.com, taken from howsmyssl_com_root_cert.pem
The PEM file was extracted from the output of this command:
openssl s_client -showcerts -connect www.howsmyssl.com:443 </dev/null
The CA root cert is the last cert given in the chain of certs.
To embed it in the app binary, the PEM file is named
in the component.mk COMPONENT_EMBED_TXTFILES variable.
*/
extern const char howsmyssl_com_root_cert_pem_start[] asm("_binary_howsmyssl_com_root_cert_pem_start");
extern const char howsmyssl_com_root_cert_pem_end[] asm("_binary_howsmyssl_com_root_cert_pem_end");
esp_err_t _http_event_handler(esp_http_client_event_t *evt)
{
switch(evt->event_id) {
case HTTP_EVENT_ERROR:
ESP_LOGE (TAG, "HTTP_EVENT_ERROR");
break;
case HTTP_EVENT_ON_CONNECTED:
ESP_LOGE (TAG, "HTTP_EVENT_ON_CONNECTED");
break;
case HTTP_EVENT_HEADER_SENT:
ESP_LOGE (TAG, "HTTP_EVENT_HEADER_SENT");
break;
case HTTP_EVENT_ON_HEADER:
ESP_LOGE (TAG, "HTTP_EVENT_ON_HEADER, key=%s, value=%s", evt->header_key, evt->header_value);
m_time_start = xTaskGetTickCount();
if(strcmp("Content-Length",evt->header_key) == 0){
filesize_count = atoi(evt->header_value);
}
break;
case HTTP_EVENT_ON_DATA:
filesize_count -= evt->data_len;
//ESP_LOGE (TAG, "HTTP_EVENT_ON_DATA, len=%d content left=%d bytes ", evt->data_len, filesize_count);
if (!esp_http_client_is_chunked_response(evt->client)) {
// Write out data
// printf("%.*s", evt->data_len, (char*)evt->data);
}
break;
case HTTP_EVENT_ON_FINISH:
ESP_LOGE (TAG, "HTTP_EVENT_ON_FINISH");
m_time_end = xTaskGetTickCount();
int a = (m_time_end - m_time_start) / configTICK_RATE_HZ;
int b = (m_time_end - m_time_start) % configTICK_RATE_HZ;
ESP_LOGE (TAG, "TIME OF EXECUTION: %d.%d", a, b);
break;
case HTTP_EVENT_DISCONNECTED:
ESP_LOGE (TAG, "HTTP_EVENT_DISCONNECTED");
break;
}
return ESP_OK;
}
static void http_download_chunk()
{
esp_http_client_config_t config = {
.url = "http://ftp.auckland.ac.nz/putty/putty-0.55.tar.gz",
.event_handler = _http_event_handler,
.buffer_size = 10240 // Dodao za ubrzanje
};
esp_http_client_handle_t client = esp_http_client_init(&config);
esp_err_t err = esp_http_client_perform(client);
if (err == ESP_OK) {
ESP_LOGI(TAG, "HTTP chunk encoding Status = %d, content_length = %d",
esp_http_client_get_status_code(client),
esp_http_client_get_content_length(client));
} else {
ESP_LOGE(TAG, "Error perform http request %s", esp_err_to_name(err));
}
esp_http_client_cleanup(client);
}
static void http_test_task(void *pvParameters)
{
app_wifi_wait_connected();
ESP_LOGE(TAG, "Connected to AP, begin http example");
/* http_rest();
http_auth_basic();
http_auth_basic_redirect();
http_auth_digest();
http_relative_redirect();
http_absolute_redirect();
https();
http_redirect_to_https();*/
http_download_chunk();
/*http_perform_as_stream_reader();
https_async();*/
ESP_LOGE(TAG, "Finish http example");
vTaskDelete(NULL);
}
void app_main()
{
esp_err_t ret = nvs_flash_init();
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
ESP_ERROR_CHECK(nvs_flash_erase());
ret = nvs_flash_init();
}
ESP_ERROR_CHECK(ret);
app_wifi_initialise();
xTaskCreate(&http_test_task, "http_test_task", 8192, NULL, 5, NULL);
}
Re: What download speeds are available on WiFi?
I was able according to my calculations - to get bandwidth of 9 megabyte/s through STA mode and router in close proximity around 1-2m from the module. The bandwidth drops with the distance but amplified signal should work pretty fast. However I had to program a pure TCP socket-to-socket connection with large buffer around 1Mb.
Who is online
Users browsing this forum: No registered users and 171 guests