B4R Question (Solved) ESP32 - 3rd serial port

atiaust

Active Member
Licensed User
Longtime User
Hi All,

I am trying to get a 3rd serial port on a ESPRESSIF ESP-32-WROOM-32 dev board. I need to be able to monitor the debug on serial1 with an RS232/TTL converter on serial2 and a RS485/TTL converter on Serial3.

rSoftwareSerial does not work with ESP32 Boards and won't compile without errors.

#if C - for serial2 works fine.

I tried #if C for serial3

B4X:
#if C
void SerialNative3(B4R::Object* unused)
{
::Serial3.begin(4800, SERIAL_8N1, 12, 13);
b4r_main::_serialnative3->wrappedStream = &::Serial3;
}
#End If

but get the following error message

b4r_main.cpp:27:44: error: '::Serial3' has not been declared
b4r_main::_serialnative3->wrappedStream = &::Serial3;

Does anyone have any suggestions please.

Thanks
 

atiaust

Active Member
Licensed User
Longtime User
After further searching I found that it appears Serial2 is defined somewhere internally in the libraries but Serial3 needs to be defined by adding "HardwareSerial Serial3(3); // Third Serial Port" to the #if C statement.

B4X:
'RX=12 (DI), TX=13 (D0) - RS485 signals
#if C
HardwareSerial Serial3(3); // Third Serial Port
void SerialNative3(B4R::Object* unused)
{
::Serial3.begin(4800, SERIAL_8N1, 12, 13);
b4r_main::_serialnative3->wrappedStream = &::Serial3;
}
#End If
 
Upvote 1
Top