How to increase WiFi throughput

usmanmehmood55
Posts: 10
Joined: Wed Feb 03, 2021 7:54 am

How to increase WiFi throughput

Postby usmanmehmood55 » Wed Feb 03, 2021 8:07 am

Hi.
I am trying to send ADC data to a webpage created on an AP generated by the ESP32 itself, using the following code:

Code: Select all

#include <Arduino.h>
#include "WiFi.h"
#include "ESPAsyncWebServer.h"

const char *ssid = "dataAP";
const char *password = "123456789";
AsyncWebServer server(80);
#define ADC_PIN 10

String string_to_send;
bool status = false;
String send_data()
{
    if (status == true)
    {
        return string_to_send;
    }
    else
    {
        return "0";
    }
}

void setup()
{
    pinMode(ADC_PIN, INPUT);
    Serial.begin(115200);
    Serial.println();
    Serial.println("Setting AP");
    WiFi.softAP(ssid, password);
    IPAddress IP = WiFi.softAPIP();
    Serial.print("AP IP address: ");
    Serial.println(IP);
    server.on("/voice", HTTP_GET, [](AsyncWebServerRequest *request) {
        request->send_P(200, "text/plain", send_data().c_str());
    });
    server.begin();
}

char ADC_sample = 0;
void send_ADC()
{
    ADC_sample = map(analogRead(ADC_PIN), 0, 4096, 0, 99);
    string_to_send = ADC_sample;
    for (unsigned int i = 0; i <= 100; i++)
    {
        ADC_sample = map(analogRead(ADC_PIN), 0, 4096, 0, 99);
        string_to_send = string_to_send + "," + ADC_sample;
        Serial.println(ADC_sample);
    }
    string_to_send = string_to_send + ",";
}

void loop()
{
    status = false;
    send_ADC();
    status = true;
}
The current code is sending data measured by the ADC, but the built-in ADC is only good up-to 500Hz. So I will be using an external ADC with a higher sampling rate.

I want to see what maximum rate of data I can send using this method, or in fact, ANY method would do. I just want to send as much data as possible via WiFi.
Can anyone please help or guide me on how I can do that?
Your help would be much appreciated :)
Regards
Attachments
code.cpp
(1.27 KiB) Downloaded 340 times

pipi61
Posts: 60
Joined: Fri Dec 23, 2016 10:58 pm

Re: How to increase WiFi throughput

Postby pipi61 » Wed Feb 03, 2021 1:45 pm

The data transfer rate depends on the protocol used - http-udp-tcp-ftp etc.
I check transfer data from sdcard on ftp, the max speed 1MByte/sec. But this also includes the reading time of the sdcard

usmanmehmood55
Posts: 10
Joined: Wed Feb 03, 2021 7:54 am

Re: How to increase WiFi throughput

Postby usmanmehmood55 » Thu Feb 04, 2021 5:22 am

pipi61 wrote:
Wed Feb 03, 2021 1:45 pm
The data transfer rate depends on the protocol used - http-udp-tcp-ftp etc.
I check transfer data from sdcard on ftp, the max speed 1MByte/sec. But this also includes the reading time of the sdcard
Could you perhaps show me how to do that as well? 1 MByte/s is well above what I want to achieve, so it would help me tremendously.
Thank you so much. :)

pipi61
Posts: 60
Joined: Fri Dec 23, 2016 10:58 pm

Re: How to increase WiFi throughput

Postby pipi61 » Mon Feb 08, 2021 7:13 pm

try
https://github.com/d-a-v/ESPWebDAV
https://github.com/fa1ke5/ESP32_FTPServer_SD_MMC
but these access data from filesystem (SPIFFS, SDCARD etc.)
If You need send data in realtime , then check in your arduino examples: WiFiClient , WiFiUDPClient

Who is online

Users browsing this forum: No registered users and 32 guests