Serial communication using hardware port WT32-ETH01

Hi, I am trying to use RXD, TXD port inside my WT32-ETH01 to read RS232-TTL input,
What is the way to do it?

I have plugged my RS232-TTL to RXD(5) and TXD(17)

what is the correct way to access it:

#define RXD2 5
#define TXD2 17

void setup() {
  // Note the format for setting a serial port is as follows: Serial2.begin(baud-rate, protocol, RX pin, TX pin);
  Serial.begin(115200);
	
  Serial1.begin(9600, SERIAL_8N1, RXD2, TXD2); // or should I use Serial1.begin(9600)
  Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2); // or should I use Serial2.begin(9600)

}

void loop() {
  Serial.print(char(Serial2.read()));
  delay(1000);
}

Thanks!

Both, Serial1 and Serial2 should work. Modern 32bit MCUs often have a flexible hardware configuration management so you can use most pins for most functions, in contrary to the AVR series of MCUs where every pin is hard-wired to specific functions.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.