I'm trying to communicate an RS232 device with an ESP32 (Heltec Wifi/LoRa 32 v2) my problem is that I don't receive any response from the device, doing some research, I'm thinking that the trouble can be the flow control because I don't use these pins and the modules I've used neither have these pins. Do you know a way to, at least, solder the DB9 pins to have a sort of flow control to communicate the devices?

  • What kind of device are you trying to communicate with?
    – StarCat
    Mar 6, 2020 at 14:32
  • 2
    Also: do you use a TTL->RS232 converter?
    – StarCat
    Mar 6, 2020 at 14:39
  • This can only be answered by looking at the data sheet of "the RS232 device". You can emulate RTS/CTS flow control by connecting them to two unused GPIO pins and then taking care of them in your own code while sending data back and forth. Also, a real RS232 interface communicates on signal levels between 3 and 15V, so if you are not absolutely sure that "the RS232 device" answers on a signal level of less than 3.6V, you will absolutely need a level shifter. Better use a dedicated RS232 shield for that -- which is the only answer I can give from the information in the question.
    – orithena
    Mar 6, 2020 at 21:28

1 Answer 1


You could use ESP-IDF calls to setup your UART correctly for hardware serial communication on pin 4 and 5 (and perhaps also other pins).

In the sample below, you just have to:

  • assign UART_CLIENT_RTS and UART_CLIENT_CTS to the pins of your need
  • change uart_config_t to whichever parameters are relevant for your RS232 device
    #define BUFFER_SIZE 1024

    #define UART_CLIENT_TXD  (GPIO_NUM_4)
    #define UART_CLIENT_RXD  (GPIO_NUM_5)
    #define UART_CLIENT_RTS  (GPIO_NUM_?) // Set this
    #define UART_CLIENT_CTS  (GPIO_NUM_?) // Set this
    uart_port_t uartNum = UART_NUM_1;

    uart_config_t uart_config = { // Set this
        .baud_rate = 115200,
        .data_bits = UART_DATA_8_BITS,
        .parity    = UART_PARITY_DISABLE,
        .stop_bits = UART_STOP_BITS_1,
        .flow_ctrl = UART_HW_FLOWCTRL_CTS_RTS
    uart_param_config(uartNum, &uart_config);
    uart_driver_install(uartNum, BUFFER_SIZE * 2, 0, 0, NULL, 0);

Communication can be done with the various uart_write_* and uart_read_* methods as defined in the documentation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.