GPIO20/21 for general use on ESP32-C3?

My project's key element is a knob display which is built around an ESP32-C3, but unfortunately just one single GPIO is available for use (GPIO3).
The problem is that I actually need 2 GPIO ports, one for input (GPIO3 is perfect) and one for output. Fortunately I can see that also GPIO20 and GPIO21 are available on the connector but labeled as UART RX/TX.
My question is whether I'm allowed to use one of these ports (probably mapped/reserved for serial communication) for my purposes (digital output). I can happily give up the UART functionality (even if debugging might be more difficult in this way) if this is the price I have to pay.

Please post a link to the module, and explain how you are currently uploading programs.

Usually, this is through pins labeled RX and TX (or RX0/TX0, U0R/U0T, etc.), but those functions may be assigned to other pins.

The ESP32 provides great flexibility in (re)assigning pin functions. See for example ESP32 Pinout Reference: Which GPIO pins should you use? | Random Nerd Tutorials

This is the documentation I have.
I haven't received yet the module but I have the standard 4 pins for USB (5V, GND, D+, Dāˆ’) available (and also present on the development board to be shipped) hence I think uploading will happen through USB with no involvement of standard UART pins.

Yes you can, but if you MCU is on a devkit board there is a good chance that these pins are connected to the USB to TTL converter on the board, which may complicate things (particularly for the rx pin) Ah hold on the C3 has native USB, you can disregard my concern. Just don't call Serial.begin() in your sketch.

What does the "knob display" do, and what pins are in use for that?

The USB connections appear to be reserved for programming, but the documentation is otherwise atrocious.

I think the knob display originally would read the encoder ring's position, and together with the button pushed status would send it on UART.
But I don't need this as all I do everyting (snart thermostat) inside the knob, on the ESP32 ā€“ as opposite to intended use of external controller (an using the esp32 just ofr display). Exception is the temperature reading (on GPIO3) and a 433 MHz remote control output I'm looking a GPIO pin for.

Documentation is confusing imo, you`ll see when you get the board..
Usually, GPIO21 and 22 are the default SCL / SDA pins for I2C communication for ESP32, not sure about C3 version..

UART RX and TX are defaluts for GPIO20ā€“21.

1 Like


ESP32 chip is in that round black knob, not under green pcb with usb connector?

Sure, it's in the knob. The green PCB is jost for interfacing/testing/connecting to USB.

brave_19iKNLDVth
So only these are available.. If the pcb inside knob is accesible, you could solder two unused pins on the chip to the flat cable pins 4 and 5.

Obviously only these are available. But the question is whether I can use either RX(GPIO20) or TX(GPIO21) for custom output pin if I assume that I won't use UART for any purposes.

i would suspect so, but we won't know until you try. Basically as i stated before, as long as there is no USB to TTL converter attached to it, there is no reason it would not work.
ESP32 tend to have more peripherals than pins to accommodate them.

I can't imagine why that would not work, if the code running is your own. Try it and see: put an LED with a 2.2K current limiting resistor from the pin to ground for testing purposes.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.