Using the RS-232 Full Pinout Breakout with Arduino involves wiring up the breakout to your Arduino-compatible microcontroller with an external RS-232 device and running the provided example code.


Wiring
Wire as shown for a 5V board like an Uno. If you are using a 3V board, like an Adafruit Feather, wire the board's 3V pin to the breakout VIN.
First, plug in an RS-232 device to the DE-9 connector on the RS-232 breakout. Then, wire up the Adafruit Metro to the breakout:
- Metro 5V to breakout Vin (red wire)
- Metro GND to breakout GND (black wire)
- Metro pin 2 to breakout RX (green wire)
- Metro pin 3 to breakout TX (blue wire)
Here is an Adafruit Metro wired up using a solderless breadboard:
- Metro 5V to breakout Vin (red wire)
- Metro GND to breakout GND (black wire)
- Metro pin 2 to breakout RX (green wire)
- Metro pin 3 to breakout TX (blue wire)
There are no additional libraries needed for this example.
Example Code
You can change the baud rate for your RS-232 device at the top of the code by editing the baud
define:
#define baud 38400
// SPDX-FileCopyrightText: 2024 Liz Clark for Adafruit Industries // // SPDX-License-Identifier: MIT #include <SoftwareSerial.h> // update this for your RS-232 device baud rate #define baud 38400 // define RX and TX pins for the software serial port #define RS232_RX_PIN 2 #define RS232_TX_PIN 3 SoftwareSerial rs232Serial(RS232_RX_PIN, RS232_TX_PIN); void setup() { Serial.begin(115200); while ( !Serial ) delay(10); rs232Serial.begin(baud); Serial.println("Enter commands to send to the RS-232 device."); Serial.println(); } void loop() { if (Serial.available() > 0) { String userInput = Serial.readStringUntil('\n'); userInput.trim(); // remove any trailing newlines or spaces if (userInput.length() > 0) { // send the command with a telnet newline (CR + LF) rs232Serial.print(userInput + "\r\n"); Serial.print("Sent: "); Serial.println(userInput); } } // check for incoming data from RS-232 device while (rs232Serial.available() > 0) { char response = rs232Serial.read(); // print the incoming data Serial.print(response); } delay(50); }
Upload the sketch to your board and open up the Serial Monitor (Tools -> Serial Monitor) at 115200 baud. You can send commands to your RS-232 device via the Serial Monitor. If any messages are received from the RS-232 device, they will print to the Serial Monitor.
The baud rate in the bottom right of the serial window is not the same as the baud rate of the RS-232 connection. It is the data rate to the serial monitor which is independent.
The commands that you send will vary by the RS-232 device that you connect to the RS-232 breakout. The output above was sent to a StarTech HDMI switcher. The AVI=n
commands switch the selected HDMI port and the VS
command gives a current status of the device.
Page last edited January 21, 2025
Text editor powered by tinymce.