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

BrianP
Posts: 53
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: 53
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: 8
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: 53
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.

Who is online

Users browsing this forum: No registered users and 54 guests