HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi
You can watch a full video version with more details here.
I know, I know, the title is a bit click-baity. But you try coming up with a constant stream of entertaining titles!
What are we talking about? This line of code that appears in pretty much every single Arduino sketch/project:
This line of code is everywhere - a quick search on GitHub finds over 450,000 instances of it.

I started to question this when I was testing out my new boards. I was streaming audio from the board and noticed that the rate I was receiving data at bore no relation to the baud rate I was setting.

If we look closely at the image, we can see that we connected to the serial port at 115200 baud. This matches exactly what I put in the Serial.begin
of the firmware.

This baud rate (115200) should give us 14.4kByte/s. But if we look at the rate at which we are receiving data, we can see that it is much higher. 94.7kByte/s.

What on earth is going on?
Well, my board is based around an ESP32-S3. This has native USB support - and the serial connection is running over the USB connection.
We don’t have a USB-to-serial converter on the board.
There is no UART.
Which means there’s no actual baud rate (this is not strictly true, it is possible to find out what the baud rate was set to - but that’s for another day).
I did a quick test to confirm this - I ran the firmware with 115200 and then connected with a python script that tried a variety of baud rates.
As you can see from the results - everything just worked.

A good question to ask now is, just how fast can we send data? What’s the limit?
Well, USB Full Speed is 12Mbit/s. With overheads and other factors, realistically we should be able to get around 9.6Mbit/s.
So I wrote another quick bit of code to test this. The firmware sends out a 4MB payload and a python script received it. Just to make sure there’s no cheating I run a CRC check on the data.
With an arduino version of the firmware, I was able to get over 7MB/s.

With the ESP32-S3 version of the firmware, I was able to get over 5MB/s.

The IDF is surpsingly slower than the Arduino version. There’s is an issue open at the moment on the ESP32 TinyUSB implementation that may fix this at some point.

Obvisouly, my tests are very much raw performance tests. Real world behaviour is likely to be very different.
But it’s interesting none the less. Obviously, with boards that have a UART, you will be limited by the ESP32 UART hardware. I believe this maxes out at 5Mbit/s but I’m planning to test this soon.
UPDATE - I gave it a quick test on an old ESP32 board with a USB-to-serial converter and got 2.26 Mbit/s. This is with a baud rate set to 3,100,000 - which is the highest I set it to and get consistent results.
All my test code is available on GitHub.
Have a watch of the video - it’s got some fun bits and more details.
Related Posts
ESP32-S3 USBMSC - Can we make it faster? - After lots of tinkering, I've managed to improve the speed of writing to the SD Card of my ESP32-TV considerably, but it's still not as fast as I'd like. The Arduino 'readRaw' and 'writeRaw' functions were the culprits, they can only write one sector at a time! After bypassing this and using IDF functions, writing speed improved by 70%. I also experimented with writing to the SD Card in the background, which ironically yielded even better results. However, it's still slower than I'd like, so I've got a crazy new plan: using a cheap IC (GL823) for SD card interfacing and a USB multiplexer switch to swap connections between ESP32 and GL823. It's a wild ride, but that's how we make progress!
Minimalist Microcontroller: Building a Bare-Bones Dev Board - In a thrilling DIY endeavour, I attempted to build the most minimalist ESP32 dev board possible. Diving deep into the schematic of the ESP32 S3 WROOM module, I chopped out the non-essentials and whittled our needs down to bare bones. The experiment saw me juggling USB data lines and voltage regulators, waving goodbye to an array of capacitors and connectors and boldly embracing the simplicity of direct connections. Despite a few hitches, the miniature Frankenboard came alive, proving that sometimes less is more...at least in the world of microcontrollers.
ESP32-S3 Hardware SPI on the Adafruit ST7789 - I've had some commenters point out the issue with the slow display updates in my recent Arduino Nano ESP32 video. It turns out, the software SPI of the Adafruit_ST7789 library was the culprit. Lo and behold, the solution is simple - using the hardware SPI constructor of the library. Apparently, this isn't well documented, so I wrote some code to serve as reference for myself and others who might run into the same snags. Trust me, the difference in speed is absolutely bonkers. Check out the video to see the magic in action.
ESP32 TV Version 3 - In the latest board revision, I've successfully resolved some key issues, including a USB interface conflict between the USB2244 and the ESP32 and a risky battery charging mistake—no more direct USB 5V to the battery! Plus, I managed to wrap this up without any clumsy bodge wiring. I've even introduced a new feature: a microphone is now on board, setting the stage for some exciting future projects. Stay tuned for what's coming!
A Faster ESP32 JPEG Decoder? - An intriguing issue appeared in the esp32-tv project that deals with speeding up JPEG file decoding using SIMD (Single Instruction Multiple Data) instructions, showing immense performance boost. However, there were some notable differences in speed when it comes to drawing the images versus simply decoding them. The problem was found to be with the DMA drawing mechanism and the way the new fast library decodes the image all at once. But despite this hiccup, by overlapped decoding and displaying process, a high frame rate can still be achieved. Joined me in this dissecting process and my initial tests showing approximately 40 frames per second display rate, on our journey to find the most efficient way to get images on screens.
Related Videos
ESP32 SD Card Speedup With a Couple of Lines of Code - In this video, we explore the disappointingly slow data writing speed of the ESP32 when reading and writing to an SD card in our TinyTV project. With 500 kilobytes/sec reading and a dismal 270 kilobytes/sec writing, we embark on an adventure to find a solution. After ditching the Arduino code in favor of IDF functions, we discover incredible improvements. Seeing potential risks, I propose a truly bonkers plan: using a IC to interface SD cards with USB with a USB multiplexer switch and another switch to alternate between ESP32 and the GL823. This could be a total disaster, but I'm game for the challenge. Stay tuned to see if it works out!
This Number Does Nothing… when you have native USB - This video's all about how the baud rate setting on an ESP32S3 with native USB does absolutely nothing. Testing with different baud rates showed no effect on performance; every rate worked flawlessly. With USB full speed, you can expect data transfers of up to 7 megabits per second. So, baud rate? Totally irrelevant with native USB—it's full steam ahead, folks! Grab my test code from GitHub, give it a go, and share your results in the comments. If that blew your mind, don't forget to like and subscribe for more ESP32 insights!
Can You Spot the Problem? - Buckle up folks, this video is a thrilling one! There's everything from unboxing my new ESP32 TV boards that arrived from PCB Way to discovering some hidden issues. We're talking about some pesky problems, surprises, and even a potential catastrophic error that could've led to a disaster. The main dish is the high-speed SD card access over USB - ultimately achieving a whooping transfer rate! But, the journey is a roller-coaster ride, from the project completely failing initially, to some smart hacks and triumphant moments. All the peripherals worked well, from the display to the sound amplifier and even the infrared receiver. Despite the ups and downs, there's a lot to learn and that's what makes this video exciting! Can't wait to share the improvements I have in mind for turning the prototype into the ultimate all-in-one device. But first, let's address the elephant in the room - an ill-placed diode that's a ticking bomb, because you know, safety first!
ESP32-S3 - Which Pins Are Safe To Use? - In this video, I've decided to dive deep into the ESP32-S3, a module ruling my lab recently due to its plug-in-and-play functionality, and the flexibility offered by its GPIO matrix. However, working with it requires vigilance, especially with regard to the strapping pins and USB data pins, among others. Discovering such quirks, I've encountered unexpected values, short glitches and the occasional code crash. To help you avoid these bumps, I've documented everything I've learned on my GitHub repo, where I'm inviting you, my fellow makers and engineers, to contribute your valuable experiences and findings. After a minor hiccup with my ESP32-TV, expect an updated PCB design, courtesy of PCBWay. Explore the ESP32-S3 with me, and let's unravel its secrets together, one pull request at a time.
ESP32 and GPS - Learn how to connect a GPS board to an ESP32 and parse location data using the Arduino framework while walking around. This tutorial also includes tips on troubleshooting serial connectivity with a USB to UART board and a terminal program.
HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi