• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

Wifi Data Transfer Speed

Q&A Forum › Category: ESP32 › Wifi Data Transfer Speed
0 Vote Up Vote Down
grog asked 6 years ago

Hello:
I want to transfer data from a micropython app running on the ESP32. Very simple, running a single ADC channel and sending:
for k in range(0,1000):
    #read and add delimiter
    txData1 = str(input1.read()) + ‘\n’
    conn.send(txData1)
Using this loop, what is the fastest I can expect to receive data in a PC application connected to the ESP32 WiFi? Assume that it sends 2 bytes per read for ADC values from 0 to 4095.
The PC is running much faster so speed isn’t an issue on that side. Also – I’m assuming the ESP32 defaults to the fastest speed of processor execution. (maybe not?)
Thanks,
Gary
 

Question Tags: Data transfer speed
5 Answers
0 Vote Up Vote Down
grog answered 6 years ago

Forgot to mention – My board is using a very recent micropython firmware. 
I did a bit of testing to figure out if the issue was with A/D conversion or the link.
Using the A/D to convert a sine wave input, I was able to send 10.072K bytes in 5.7 seconds. If we don’t include any bit stuffing or link overhead, that works out to around 15k bits/sec.
Using an integer and sending the same way, it took a bit less time, 4.3 sec, or 19.5k bits/sec. So the conversion doesn’t add much overhead.
So…those numbers do not look at all right. I’ve seen link speeds of 10Mbits for the ESP32. Whoa, something is really broke. Is the processor running slow? The “client” is a Lenovo laptop with a Realtek wireless adapter, about 15ft away.
Any ideas on this?
 

0 Vote Up Vote Down
DK answered 6 years ago

Hi

If you are using the same home Wifi Router. when here is a lot of traffic,

some of your data being sent can get lost ie. using SKY Netflex Steam slows down most routers

Its best to use a separate wifi router for esp32

Use handshaking in the for loop …
i.e
after
conn.send(txData1) //sending to client
the server then sends back acknowledgement   ack
or

just a delay function of 100ms to 500ms

usually A/D have a sample rate, this determines max speed
https://www.youtube.com/watch?v=RlKMJknsNpo

https://www.youtube.com/watch?v=CbacRysML5c

https://www.youtube.com/watch?v=Z-sDHDI6FFY

might help

0 Vote Up Vote Down
grog answered 6 years ago

Hi, thanks for the input.

The ADC loop on it’s own, without doing anything but read the 3 ADC inputs, takes 217ms for 1000 iterations. This seems about right.

So I see the real issue now. It’s the python code that’s slowing it down immensely. The conversion to a string is choking the loop. Sending formatted string bytes is killing the loop execution!

conn.sendall( bytes((txData1 + txData2 + txData3), “utf-8”))
where txDatax is just a formatted string from the ADC

Wow…any idea how to speed this up? How does a wireless link possible achieve data rates anywhere near the megabit range if they send data formatted this way? I checked the board, it’s running at full speed of 240MHz.

 

0 Vote Up Vote Down
Dusty answered 6 years ago

I haven’t tried this yet, but you can probably improve speed by moving the slow code to its own C module: https://micropython-dev-docs.readthedocs.io/en/latest/adding-module.html

Hard to say if this is any better than just writing the whole thing in C, though – I guess it depends on the project and whether you’ll use it again or not.  Personally, I’ve stuck with C for Arduino stuff, and I move as much logic to the PC as possible, because I much prefer working with Python.

0 Vote Up Vote Down
grog answered 6 years ago

I’ve discovered this is strictly an issue with string conversion, so I’ll need to sort that out in terms of a better method.
 

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.