1

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?

asked Mar 6, 2020 at 14:23
3
  • What kind of device are you trying to communicate with? Commented Mar 6, 2020 at 14:32
  • 2
    Also: do you use a TTL->RS232 converter? Commented 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. Commented Mar 6, 2020 at 21:28

1 Answer 1

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
  • set flow_ctrl to UART_HW_FLOWCTRL_RTS, UART_HW_FLOWCTRL_CTS, UART_HW_FLOWCTRL_CTS_RTS or UART_HW_FLOWCTRL_MAX
 #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_set_pin(uartNum, UART_CLIENT_TXD, UART_CLIENT_RXD, UART_CLIENT_RTS, UART_CLIENT_CTS);
 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.

answered Sep 29, 2020 at 21:14

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.