Specifically the EPS32-S2 with the pressure sensor (Product ID: 5303). The easiest way to see the problem is probably with the code below. Serial1 has no problems, and returns 128. SerialPort2 returns 0.
I'm talking with two sensors and I've worked my way down to this. Serial1 and Tx, Rx work fine with both sensors. I cannot get the third serial port to work regardless of what pins I try, and I've searched everywhere for anyone having similar problems. Thank you for your help.
--------------Code below-----------------
HardwareSerial SerialPort2(2);
void setup() {
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.println("Starting...");
Serial1.begin(9600);
SerialPort2.begin(9600,SERIAL_8N1,13,12);
}
void loop() {
Serial.println(Serial1.availableForWrite());
delay(200);
Serial.println(SerialPort2.availableForWrite());
delay(200);
}
Cannot get third serial port to work on EPS32-S2
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- ddodd
- Posts: 18
- Joined: Wed Jan 12, 2022 9:07 pm
- bidrohini
- Posts: 202
- Joined: Thu Oct 20, 2022 10:03 am
Re: Cannot get third serial port to work on EPS32-S2
Have you tried writing serial2 instead of SerialPort2?
https://icircuit.net/arduino-esp32-hard ... ample/3181
https://icircuit.net/arduino-esp32-hard ... ample/3181
- ddodd
- Posts: 18
- Joined: Wed Jan 12, 2022 9:07 pm
Re: Cannot get third serial port to work on EPS32-S2
Thanks, but that doesn't make any difference. I saw that example before and it's doesn't declare HardwareSerial serial2(2) at the beginning.
- ddodd
- Posts: 18
- Joined: Wed Jan 12, 2022 9:07 pm
Re: Cannot get third serial port to work on EPS32-S2
When I add that declaration, your example runs, but doesn't give the expected output. The text is displayed only the first time, suggesting the same problem, that serial2 is not working. I just tried a different board, with the same results. Could it be something in my Arduino IDE settings? I have no idea what to try. Thank you.
- ddodd
- Posts: 18
- Joined: Wed Jan 12, 2022 9:07 pm
Re: Cannot get third serial port to work on EPS32-S2
When I run that example, slightly modified, as shown below it's telling me neither serial port is available (reports not available for both). IDE 2.0 didn't make a difference. I don't know what else to try, if you can give some suggestions. Thanks for your help.
--------------Code below-----------------
HardwareSerial Serial2(2);
#define RXD2 13
#define TXD2 12
void setup() {
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);
delay(1000);
Serial.println("Loopback program started");
}
void loop() {
if(Serial.available()){
Serial.print("-");
Serial2.print(Serial.read());
}
else{Serial.println("Serial not available");}
if(Serial2.available()){
Serial.print(".");
Serial.print(Serial2.read());
}
else{Serial.println("Serial2 not available");}
delay(200);
}
--------------Code below-----------------
HardwareSerial Serial2(2);
#define RXD2 13
#define TXD2 12
void setup() {
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);
delay(1000);
Serial.println("Loopback program started");
}
void loop() {
if(Serial.available()){
Serial.print("-");
Serial2.print(Serial.read());
}
else{Serial.println("Serial not available");}
if(Serial2.available()){
Serial.print(".");
Serial.print(Serial2.read());
}
else{Serial.println("Serial2 not available");}
delay(200);
}
- ddodd
- Posts: 18
- Joined: Wed Jan 12, 2022 9:07 pm
Re: Cannot get third serial port to work on EPS32-S2
That's not 100% right. Serial is available if I type something in. The serial monitor repeats the '-', suggesting serial is fine. I just can't get Serial2 to respond. I have 12 and 13 wired together, per the example, and that's the only connections on the board.
- ddodd
- Posts: 18
- Joined: Wed Jan 12, 2022 9:07 pm
Re: Cannot get third serial port to work on EPS32-S2
Looks like SoftwareSerial.h is working
Please be positive and constructive with your questions and comments.