ESP32-C3 Serial.available() doesn't work over native USB - print, printf works fine

BrianP
Posts: 78
Joined: Mon Apr 13, 2020 1:48 pm

ESP32-C3 Serial.available() doesn't work over native USB - print, printf works fine

Postby BrianP » Wed Feb 01, 2023 10:33 pm

This is a weird one.

I am using USB serial emulation to debug some code. So the native, built in USB controller with no USB to serial chip. I can program the ESP no problem, and Serial.print as well as printf work perfectly.

I have tried using the Arduino serial console, Teraterm and Putty (the latter I can disable flow control). The relevant code fragment is

if( Serial.available() > 0 ) {
input = Serial.read();

I never get a NZ value for Serial.available. I have even tried the Arduino example to the same effect.

I downloaded and installed ESP-IDF, which I expect to install the USB driver, but device manager says it is using the Microsoft driver date 2006, version 10.0.22621.160. Updating the driver has no effect.

Any suggestions?

Thanks!

BrianP
Posts: 78
Joined: Mon Apr 13, 2020 1:48 pm

Re: ESP32-C3 Serial.available() doesn't work over native USB - print, printf works fine

Postby BrianP » Thu Feb 02, 2023 1:00 am

I think I figured it out. Pretty hard to find with the googles but for the benefit of the next person look at this reddit reply
https://www.reddit.com/r/esp32/comments ... e/hzoq904/

In my case, I edited board.txt as found at \AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.6 and changed the lines

esp32c3.serial.disableDTR=false
esp32c3.serial.disableRTS=false

to

esp32c3.serial.disableDTR=true
esp32c3.serial.disableRTS=true

User avatar
0miker0
Posts: 10
Joined: Fri Dec 01, 2017 1:14 pm

Re: ESP32-C3 Serial.available() doesn't work over native USB - print, printf works fine

Postby 0miker0 » Thu Feb 02, 2023 12:08 pm

Uploading sketches and serial data worked so intermit and poorly for me that I ended up adding a CP2104 usb chip. After that it all worked perfectly. I was hoping after a few updates it would work better but nope.

BrianP
Posts: 78
Joined: Mon Apr 13, 2020 1:48 pm

Re: ESP32-C3 Serial.available() doesn't work over native USB - print, printf works fine

Postby BrianP » Thu Feb 02, 2023 1:03 pm

I have mostly had to overcome "hurdles" like this one where things don't work, I solve the problem and then they work no problem since then.

I think part of the issue is that internal ESP internal USB challenges are not particularly well documented so you can hit a brick wall pretty easily. Even things like making sure the states of IO2, 8, and 9 (and 9 being used as a boot switch) at bootup should be in bold in the documentation.

So I have been able to program via internal USB without any issues once I figured those things out, and have only had issues with serial emulation with this issue. The issue baffles me because its an Arduino file (boards.txt) and I wasn't using the Arduino serial console.

I'm biased though: I think the Arduino software platform is an abomination but I'm using it so my friend can modify the code after I'm done.

hokahonay
Posts: 4
Joined: Wed Dec 04, 2019 10:32 am

Re: ESP32-C3 Serial.available() doesn't work over native USB - print, printf works fine

Postby hokahonay » Tue Aug 12, 2025 6:10 pm

it seems that esp32??? serial port is a complete flying rooster
i've spent days trying to get it working when i tripped over this thread
SO
i edited boards.txt
changed every occurance of .serial.disableDTR=false to true
and every occurance of .serial.disableRTS=false to true
closed arduino, re-opened arduino and uploaded the sketches again
now some serial monitors work and some dont, I am using ESP32 DEV units and ESP32S3 units
whether they work or not seems to be a complete lottery

either Arduino and or Espressif need to get their acts together we are buying your devices and using your firmware
AND NOW IT LOOKS AS THOUGH WE ARE TROUBLE SHOOTING FOR YOU AS WELL
where does your part come in ???????

and extreemly cheesed off Dave

BrianP
Posts: 78
Joined: Mon Apr 13, 2020 1:48 pm

Re: ESP32-C3 Serial.available() doesn't work over native USB - print, printf works fine

Postby BrianP » Wed Aug 13, 2025 12:48 am

FWIW, I stopped using Arduino and deleted all Arduino related stuff from my computer shortly after my last post. I also exclude the term Arduino from all Google searches. Everything I do now is c language and FreeRTOS only.

There is simply too much garbage floating around the Arduino world to waste any time on it.


hokahonay
Posts: 4
Joined: Wed Dec 04, 2019 10:32 am

Re: ESP32-C3 Serial.available() doesn't work over native USB - print, printf works fine

Postby hokahonay » Fri Aug 15, 2025 10:13 am

being unable to give up on a problem i reported this issue at https://github.com/espressif/arduino-esp32/issues/11725
with guidance from Ibernstone, on my system I have proved that this is an Arduino 2.3.6 problem
first thing was to put boards.txt back to the original (changing boards.txt i felt was wrong, the developers know what they are doing)
running the code below on Arduino 1.8.19 works perfectly
running the same code on Arduino 2.3.6 does not work
i am about to report the issue to Arduino developers

Code: Select all

void setup() {
Serial.begin(115200);
while(!Serial);
Serial.println("Serial started");
}

String kbdInput = "";
bool inptrdy = false;
void loop() {
//-------------------
if(Serial.available()) {
char c = Serial.read();
if(c != 13) {
kbdInput += c; // add c to string
}
else inptrdy = true;
Serial.print("serial ok c: ");
Serial.println(c);
Serial.println("kbdInput: " + kbdInput);
Serial.println("inputrdy: " + inptrdy);
}
if(inptrdy) {
Serial.println("inptrdy true kbdInput: " + kbdInput);
if(kbdInput == "c") {
Serial.println("Keyboard commands:");
}
else if(kbdInput == "tables") { // print tables
Serial.println("printTheTables()");
}
else if(kbdInput == "restart") { // restart node
Serial.println("Power On Reset this node");
}

kbdInput = "";
inptrdy = false;
}
}
Dave

Who is online

Users browsing this forum: ChatGPT-User, Google [Bot], Qwantbot, Semrush [Bot] and 2 guests