ESP32-WROVER-B WiFi <1.2Mbps

chr1st0s
Posts: 15
Joined: Fri Nov 01, 2019 10:05 am

ESP32-WROVER-B WiFi <1.2Mbps

Postby chr1st0s » Fri Apr 17, 2020 10:00 am

Hi,

We have been testing the download speed of ESP32-WROVER-B WiFi using a modified version of esp-idf example “esp_http_client_example”. The download speed, either from Amazon or from Dropbox download link, doesn't exceed 1.2Mbps (~120Kbytes / second). I would expect at least x2-3 times that speed. Is there a configuration we are missing?

The module is within 1 meter distance from the hotspot, and my mobile phone has ~12Mbps download speed from the same hotspot. Also, the example code (below) is built with the default idf settings, but our application that achieves the exact same performance has been also built with the setting below without any luck of download speed improvement:

- Flash SPI mode as QIO & at 80MHz
- Component config > LWIP > TCP > Maximum Segment Size to 13KByte
- Increase task priority (24)
- Change the `((esp_http_client_config_t)config).buffer_size` in various lengths from 4 to 17KBytes, no significant difference.

Test code:

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.
*/

#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 17 * 1024
static const char *TAG = "HTTP_CLIENT";

/* 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_LOGD(TAG, "HTTP_EVENT_ERROR");
            break;
        case HTTP_EVENT_ON_CONNECTED:
            ESP_LOGD(TAG, "HTTP_EVENT_ON_CONNECTED");
            break;
        case HTTP_EVENT_HEADER_SENT:
            ESP_LOGD(TAG, "HTTP_EVENT_HEADER_SENT");
            break;
        case HTTP_EVENT_ON_HEADER:
            ESP_LOGD(TAG, "HTTP_EVENT_ON_HEADER, key=%s, value=%s", evt->header_key, evt->header_value);
            break;
        case HTTP_EVENT_ON_DATA:
            ESP_LOGD(TAG, "HTTP_EVENT_ON_DATA, len=%d", evt->data_len);
            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_LOGD(TAG, "HTTP_EVENT_ON_FINISH");
            break;
        case HTTP_EVENT_DISCONNECTED:
            ESP_LOGD(TAG, "HTTP_EVENT_DISCONNECTED");
            break;
    }
    return ESP_OK;
}



static void http_download_chunk()
{
    esp_http_client_config_t config = {
        .url = "https://www.dropbox.com/......?dl=1",
        .event_handler = _http_event_handler,
        .buffer_size = 17 * 1024,
    };
    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_LOGI(TAG, "Connected to AP, begin http example");
    http_download_chunk();
    ESP_LOGI(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, 24, NULL);
}
Thank you,
Christos

chr1st0s
Posts: 15
Joined: Fri Nov 01, 2019 10:05 am

Re: ESP32-WROVER-B WiFi <1.2Mbps

Postby chr1st0s » Fri Apr 17, 2020 12:18 pm

Following https://esp32.com/viewtopic.php?t=4215 , reply by ESP_Angus suggestion to copy sdkconfig from ipref example, ~15Mbps.

Who is online

Users browsing this forum: No registered users and 341 guests