ESP32 S3 - RS232

In this tutorial, we explore how to use RS232 communication with the ESP32 S3 board. We will cover everything from wiring the TTL to RS232 module to programming the ESP32 S3 to send and receive serial data over RS232.

What you'll build:

  1. Connect an ESP32 S3 to a TTL to RS232 module
  2. Configure the ESP32 S3 UART to communicate over RS232
  3. Send data from the ESP32 S3 to an RS232 device
  4. Receive and echo data from an RS232 device back through the Serial Monitor
RS232 RS232

Overview of TTL to RS232 Module

When using serial communication with Serial.print(), Serial.read(), and Serial.write() functions on the ESP32 S3, the board outputs data through its TX pin and reads data from its RX pin at TTL voltage levels. TTL signals are suitable for short-distance communication only, so when you need to transmit data over longer distances or connect to legacy industrial equipment, a signal converter such as the TTL to RS232 module is required. The TTL to RS232 module converts TTL signals to the RS232 standard and vice versa, making it straightforward to interface the ESP32 S3 with RS232-compatible devices.

Key Specifications

The TTL to RS232 module bridges two electrical standards:

  • Operates with both 5V and 3.3V TTL logic levels
  • Uses a DB9 female D-Sub connector for the RS232 interface
  • Typically based on the MAX3232 chip for 3.3V compatibility

Pinout

The RS232 to TTL module exposes two distinct interfaces — a TTL side that connects to the ESP32 S3, and an RS232 side that connects to the serial device.

  1. VCC pin — power pin, connect to VCC (5V or 3.3V)
  2. GND pin — power pin, connect to GND (0V)
  3. RXD pin — data pin, connect to a TX pin of the ESP32 S3
  4. TXD pin — data pin, connect to a RX pin of the ESP32 S3
  5. DB9 female connector — RS232 interface, connect to the serial device
RS232 Pinout

Wiring Diagram

Connect the TTL to RS232 module to the ESP32 S3 by linking the module's VCC to 3.3V, GND to GND, RXD to an ESP32 S3 TX pin, and TXD to an ESP32 S3 RX pin. Double-check your TX/RX cross-connection before powering the circuit to avoid communication issues.

Safety Notes

The ESP32 S3 operates at 3.3V logic levels. Ensure your TTL to RS232 module is compatible with 3.3V (modules based on the MAX3232 are recommended). Avoid connecting the module's VCC to 5V if the module is not rated for it, as this could damage the ESP32 S3 I/O pins.

ESP32 S3 TTL to RS232 Module
3.3V VCC
GND GND
GPIO17 (TX) RXD
GPIO18 (RX) TXD
  • How to connect ESP32 S3 and RS232 to TTL module using breadboard
The wiring diagram between ESP32 S3 TTL to RS232

This image is created using Fritzing. Click to enlarge image

How To Program ESP32 S3 to Use the RS232 Module

Programming the ESP32 S3 for RS232 communication follows the standard Arduino Serial API, with the conversion handled transparently by the TTL to RS232 module. You initialize a hardware serial port, configure the baud rate, and then use familiar read() and write() functions to exchange data. The following code shows how to initialize both the Serial Monitor and the RS232 serial port on the ESP32 S3.

  • Initializes the Serial interface:
Serial.begin(9600); // Serial Monitor Serial2.begin(9600, SERIAL_8N1, 18, 17); // RS232

ESP32 S3 Code for RS232

/* * This ESP32 S3 code was developed by newbiely.com * * This ESP32 S3 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-s3/esp32-s3-rs232 */ /* * This ESP32-S3 code is created by esp32io.com * * This ESP32-S3 code is released in the public domain * * For more detail (instruction and wiring diagram), visit https://esp32io.com/tutorials/esp32-s3-rs232 */ void setup() { // start communication with baud rate 9600 Serial.begin(9600); // Serial Monitor Serial2.begin(9600, SERIAL_8N1, 18, 17); // RS232 // wait a moment to allow serial ports to initialize delay(100); } void loop() { // Check if there's data available on Serial if (Serial2.available()) { char data = Serial2.read(); // read the received character Serial.print(data); // print the recived data to Serial Monitor } }

Detailed Instructions

Follow these steps to get your ESP32 S3 RS232 project running successfully.

  1. New to ESP32 S3? Complete our Getting Started with ESP32 S3 guide first.
  2. Click to the ESP32 S3 Code for RS232 section above, copy the code, and open it in the Arduino IDE.
  3. Wire the TTL to RS232 module to the ESP32 S3 following the wiring diagram above.
  4. Connect the ESP32 S3 to your PC via USB Type-C cable.
  5. Select the correct board and COM port in the Arduino IDE.
  6. Click the Upload button to compile and flash the code.
  7. Open the Serial Monitor at 9600 baud to observe output.
  8. Connect the RS232 device (or RS232-to-USB cable) and send test data to verify two-way communication.
  9. Pro Tip: If no data appears in the Serial Monitor, double-check your TX/RX cross-connections — a swapped pair is the most common wiring mistake with RS232 modules.

Serial Monitor Output

Once the ESP32 S3 is running and connected to an RS232 device via the TTL to RS232 module, you should see output similar to the following in the Arduino IDE Serial Monitor.

Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
ESP32S3 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32S3 Dev Module' on 'COM15')
New Line
9600 baud
[2026-01-15 09:00:01] RS232 initialized. Waiting for data... [2026-01-15 09:00:05] Received: Hello from RS232 device [2026-01-15 09:00:05] Echoing back: Hello from RS232 device [2026-01-15 09:00:10] Received: Test message 123
Ln 11, Col 1
ESP32S3 Dev Module on COM15
2

Applications

RS232 communication bridges the ESP32 S3 to a wide range of legacy and industrial equipment that predates modern digital interfaces.

  1. Industrial PLC Integration: Connect the ESP32 S3 to programmable logic controllers that use RS232 for configuration or data readout.
  2. Legacy Instrument Control: Interface with older lab equipment such as oscilloscopes, signal generators, or power supplies that expose an RS232 port.
  3. GPS Receiver Communication: Many GPS modules output NMEA sentences over RS232, which the ESP32 S3 can parse for location data.
  4. Point-of-Sale Terminals: Exchange transaction data with receipt printers and barcode scanners that use RS232.
  5. Building Automation: Read data from HVAC controllers, energy meters, and access control panels with RS232 interfaces.
  6. Robotics Serial Bus: Use RS232 as a robust communication link between the ESP32 S3 and servo controllers or motor drivers in noisy environments.

Video Tutorial

Watch the step-by-step video walkthrough for this ESP32 S3 project below.

Challenges

These challenges will help you deepen your understanding of RS232 communication with the ESP32 S3 and push your project further.

  1. Beginner: Modify the code to send a "Hello from ESP32 S3!" message over RS232 every five seconds and confirm receipt on a terminal program such as PuTTY or Tera Term.
  2. Intermediate: Implement a simple command-response protocol where the ESP32 S3 reads a command string from the RS232 device and replies with different responses depending on the command received.
  3. Advanced: Build a data logger that receives structured sensor readings over RS232, parses the values, and stores them to an SD card or uploads them to a cloud service via the ESP32 S3's Wi-Fi capabilities.

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!