Getting Started with Seeed Studio XIAO-RS485-Expansion-Board

- V1.1 and earlier versions use software direction control. See the software-to-software direction example.
Features
- Compatible with Seeed Studio XIAO: Designed for Seeed Studio XIAO development boards.
- Long-Distance Communication: Supports RS-485 communication over distances of up to 1,200 m (approximately 3,937 ft).
- 5V or 12V DC Input: Supports either supply voltage, with an onboard circuit that converts 12V to 5V.
- Two 3-Pin Terminals: Separate terminals for RS-485 signals (A, B, GND) and power (INT、5V、12V).
- Compact Design: Approximately the size of two XIAO boards, making it suitable for space-constrained projects.
- Selectable Direction Control: Configure hardware automatic or software-controlled RS-485 transmit/receive switching through the onboard 0 Ω resistors. The board ships configured for hardware automatic direction control by default.
- RX/TX Activity LEDs: Indicate data reception and transmission.
- 5V and 12V Power LEDs: Indicate the presence of the corresponding input voltage
Hardware Overview
- XIAO RS485 Expansion Board
- XIAO RS485 Expansion Board indication diagram V1.2 Front

- XIAO RS485 Expansion Board indication diagram V1.2 Back

Prepared material
| Seeed Studio XIAO RS485-Expansion-Board × 2 | Seeed Studio XIAO ESP32-C3 × 2 |
|---|---|
![]() | ![]() |
Connection Schematic
- The XIAO RS-485 Expansion Board V1.2 uses the TP8485E-SR transceiver. The RS-485 signals map to the XIAO pins as follows:
RS485_TXto D4,RS485_RXto D5, andRS485_DEto D2.

| Two RS485 expansion board connections |
|---|
![]() |
- 5V OUT/IN switch: Controls the direction of power at the 5V terminal. Set it to
OUTwhen this board supplies 5V to another device, or toINwhen this board receives 5V through the terminal. - 120R switch: Set it to
ONto connect the onboard 120 Ω termination resistor across the RS-485 A and B lines, or toNCto disconnect it. For long cable runs, enable termination at the two physical ends of the bus; leave it disconnected on intermediate boards. - INT: Reserved interrupt connection.
- V1.2 is configured for hardware automatic direction control by default, so the sketch does not need to switch the direction through D2. To use software direction control, change the placement of the onboard 0 Ω resistors.
- Location of the zero-ohm resistor for hardware auto-direction

- Location of the zero-ohm resistor for software manual direction

Software Overview
In this project, the XIAO ESP32C3 communicates with the RS485 expansion board using D4 (GPIO6) and D5 (GPIO7).
Hardware automatic direction to hardware automatic direction
When hardware automatic direction control is selected, the sketch does not need to control the DE pin.
1. Sender Code
#include <Arduino.h>
// Hardware -> Hardware: sender (XIAO ESP32C3, RS485 board V1.2).
// Fit R23/R24 for automatic direction; D2 is unused.
void setup() {
Serial.begin(115200); // USB serial monitor.
Serial1.begin(9600, SERIAL_8N1, D5, D4); // RS485: RX=D5, TX=D4.
Serial.println("Hardware -> Hardware sender ready");
delay(500);
}
void loop() {
Serial1.println("Hello from hardware sender"); // Send over the RS485 bus.
Serial.println("Sent: Hello from hardware sender"); // Show status via USB.
delay(1000);
}
Serial.begin(115200)starts USB serial output for the serial monitor.Serial1.begin(9600, SERIAL_8N1, D5, D4)starts RS-485 communication at 9600 baud. D5 is RX and D4 is TX.- The board controls transmission direction automatically, so this sketch does not use D2.
Serial1.println()sends a line of text every second.Serial.println()displays the local send status through USB; it does not confirm that the receiver received the message.
2. Receiver Code
#include <Arduino.h>
// Hardware -> Hardware: receiver (XIAO ESP32C3, RS485 board V1.2).
// Fit R23/R24 for automatic direction; D2 is unused.
void setup() {
Serial.begin(115200); // USB serial monitor.
Serial1.begin(9600, SERIAL_8N1, D5, D4); // RS485: RX=D5, TX=D4.
Serial.println("Hardware -> Hardware receiver ready");
delay(500);
}
void loop() {
if (Serial1.available()) {
String message = Serial1.readStringUntil('\n'); // Read one RS485 line.
message.trim();
if (message.length() > 0) {
Serial.print("Received: "); // Display on the USB serial monitor.
Serial.println(message);
}
}
}
Serialdisplays messages through USB.Serial1receives data from the RS-485 transceiver through D5.Serial1.available()checks whether received bytes are waiting in the UART buffer.Serial1.readStringUntil('\n')reads until a newline or timeout.message.trim()removes surrounding whitespace, including the carriage return sent byprintln().- If the resulting message is not empty,
Serial.print()andSerial.println()display it in the USB serial monitor. - The board controls direction automatically, so this sketch does not use D2.
3. Test Results
- Open the USB serial monitor for each XIAO to view the sent and received messages.

- During data transfer, the onboard TX and RX indicators blink to show the corresponding activity.

Hardware automatic direction to software direction
1. Sender Code
#include <Arduino.h>
// Hardware -> Software: sender (XIAO ESP32C3, RS485 board V1.2).
// Fit R23/R24 for automatic direction; D2 is unused.
void setup() {
Serial.begin(115200); // USB serial monitor.
Serial1.begin(9600, SERIAL_8N1, D5, D4); // RS485: RX=D5, TX=D4.
Serial.println("Hardware -> Software sender ready");
}
void loop() {
Serial1.println("Hello from hardware sender"); // Send over the RS485 bus.
Serial.println("Sent: Hello from hardware sender"); // Show status via USB.
delay(1000);
}
Serial.begin(115200)starts USB serial output.Serial1.begin(9600, SERIAL_8N1, D5, D4)starts the RS-485 UART with RX on D5 and TX on D4.- This board uses hardware automatic direction control, so the sender does not need to operate D2.
- In
loop(),Serial1.println()sends a line of text over RS-485 once per second. Serial.println()displays the local send status through USB. Check the receiver's serial monitor to confirm reception.
2. Receiver Code
With software direction control, configure D2 as an output and keep it LOW on the receiver to enable receive mode.
#include <Arduino.h>
// Hardware -> Software: receiver (XIAO ESP32C3, RS485 board V1.2).
// Fit R25/R26 for software direction; D2 stays LOW to receive.
void setup() {
Serial.begin(115200); // USB serial monitor.
Serial1.begin(9600, SERIAL_8N1, D5, D4); // RS485: RX=D5, TX=D4.
pinMode(D2, OUTPUT);
digitalWrite(D2, LOW); // Keep RS485 in receive mode.
Serial.println("Hardware -> Software receiver ready");
}
void loop() {
if (Serial1.available()) {
String message = Serial1.readStringUntil('\n'); // Read one RS485 line.
message.trim();
if (message.length() > 0) {
Serial.print("Received: "); // Display on the USB serial monitor.
Serial.println(message);
}
}
}
Serialis used for the USB serial monitor, whileSerial1receives RS-485 data through D5.pinMode(D2, OUTPUT)configures D2 for direction control. Keeping D2 LOW selects receive mode.Serial1.available()checks for buffered data.readStringUntil('\n')reads a line, andtrim()removes surrounding whitespace.message.length() > 0filters out empty messages. Valid received text is displayed through the USB serial monitor.
3. Test Results
- Open the USB serial monitor for each XIAO to view the sent and received messages.

- During data transfer, the onboard TX and RX indicators blink to show the corresponding activity.

Software direction to software direction
In software direction control, D2 selects the operating mode: LOW for receive and HIGH for transmit.
1. Sender Code
#include <Arduino.h>
// Software -> Software: sender (XIAO ESP32C3, RS485 board V1.2).
// Fit R25/R26 for software direction; D2 controls transmit/receive.
void setup() {
Serial.begin(115200); // USB serial monitor.
Serial1.begin(9600, SERIAL_8N1, D5, D4); // RS485: RX=D5, TX=D4.
pinMode(D2, OUTPUT);
digitalWrite(D2, LOW); // Keep RS485 in receive mode.
Serial.println("Software -> Software sender ready");
}
void loop() {
digitalWrite(D2, HIGH); // Enable RS485 transmission.
delayMicroseconds(100); // Allow the transceiver to switch.
Serial1.println("Hello from software sender"); // Send over the RS485 bus.
Serial1.flush(true); // Wait for TX only; keep RX buffer intact.
digitalWrite(D2, LOW); // Return to receive mode.
Serial.println("Sent: Hello from software sender"); // Show status via USB.
delay(1000);
}
Serialdisplays status through USB.Serial1sends RS-485 data through D4 at 9600 baud.- D2 controls direction: LOW selects receive mode and HIGH selects transmit mode.
- Before sending, the sketch sets D2 HIGH and waits briefly for the transceiver to switch modes.
Serial1.println()sends the text.Serial1.flush(true)waits for UART transmission to finish without clearing received data.- After transmission, the sketch sets D2 LOW and displays the local send status through USB.
2. Receiver Code
#include <Arduino.h>
// Software -> Software: receiver (XIAO ESP32C3, RS485 board V1.2).
// Fit R25/R26 for software direction; D2 stays LOW to receive.
void setup() {
Serial.begin(115200); // USB serial monitor.
Serial1.begin(9600, SERIAL_8N1, D5, D4); // RS485: RX=D5, TX=D4.
pinMode(D2, OUTPUT);
digitalWrite(D2, LOW); // Keep RS485 in receive mode.
Serial.println("Software -> Software receiver ready");
}
void loop() {
if (Serial1.available()) {
String message = Serial1.readStringUntil('\n'); // Read one RS485 line.
message.trim();
if (message.length() > 0) {
Serial.print("Received: "); // Display on the USB serial monitor.
Serial.println(message);
}
}
}
Serial.begin(115200)starts USB serial output.Serial1.begin(9600, SERIAL_8N1, D5, D4)starts the RS-485 UART with RX on D5 and TX on D4.- D2 is configured for direction control and kept LOW so the transceiver remains in receive mode.
- When
Serial1.available()reports buffered data,readStringUntil('\n')reads a line. trim()removes surrounding whitespace. If the message is not empty, the sketch displays it through USB.
3. Test Results
- Open the USB serial monitor for each XIAO to view the sent and received messages.

- During data transfer, the onboard TX and RX indicators blink to show the corresponding activity.

Resources
- 📄[Schematic] Seeed Studio XIAO-RS485-Expansion-Board Schematic V1.2
- 🗃️[PCB Design Files] Seeed Studio XIAO-RS485-Expansion-Board V1.2 Project
- 📄[Schematic] Seeed Studio XIAO-RS485-Expansion-Board Schematic V1.1
- 🗃️[KiCad Schematic] Seeed Studio XIAO-RS485-Expansion-Board V1.1 SCH
Tech Support & Product Discussion
Thank you for choosing our products! We are here to provide you with different support to ensure that your experience with our products is as smooth as possible. We offer several communication channels to cater to different preferences and needs.


