Hello together,
I need for a project two serial ports, but if i check the pinout i only find one UART. Also the Hardware freeze immediately if i use Serial2 in my code.
So is there a way to and an additional Serial (with custom Port Definition) or is the XIAO RP2040 the wrong HW for my project?
I see this code, uses soft serial. I have something similar on a ESPc3 talking to GPS and Serial port. Works very well.
#include <SoftwareSerial.h>
SoftwareSerial mySerial = SoftwareSerial(21,20); // these are GPIO pins on Arduino RP2040 D9 and D8
void setup(){
Serial.begin(9600); // USB
while(!Serial); // For USB
Serial1.begin(9600); // for the provided UART port on the Nano RP2040
mySerial.begin(9600); // our custom created Serial UART interface
}
void loop(){
Serial.write("Hello World"); // writes to USB serial monitor
Serial1.write("AT"); // writes to device connected to TX and RX of the nano rp2040 e.g GSM
mySerial.write("AT"); // writes to device connected to D9 and D8 of the nano rp2040 e.g another GSM
}
HTH
GL PJ
AFAIK, it’s all or nothing when using softserial. use it for both ports.