// The Serial Monitor is routed to pin RX and TX of the ESP32.
// Question: Can that be changed to Serial2 ?
// Answer: Yes !
//
// Note: I use the default pins with Serial.setup().
//
// How to find the default RX and TX pin of Serial2:
// 1) Look into the source code.
// 2) Or use Serial2.begin(9600) in setup()
// and pause the simulation. Look at the labels.
//
// Normal routing of Serial Monitor in Wokwi:
// "connections": [
// [ "esp:TX", "$serialMonitor:RX", "", [] ],
// [ "esp:RX", "$serialMonitor:TX", "", [] ],
//
// Using Serial2 for Serial Monitor in Wokwi:
// "connections": [
// [ "esp:25", "$serialMonitor:RX", "", [] ],
// [ "esp:4", "$serialMonitor:TX", "", [] ],
void setup()
{
// Use pins 16 (RX) and 17 (TX) like this:
// Not tested if the routing of the Serial Monitor still works.
// Serial2.begin(9600, SERIAL_8N1, 16,17);
// Use default pins for Serial2.
// They are: 4 (RX) and 25 (TX)
Serial2.begin(9600);
Serial2.println("Are you seeing this? This is Serial2");
Serial2.println("Did you use 25 and 4 in diagram.json ?");
Serial2.println("Try to type something, followed by Enter.");
// The default Serial port should not be visible in the Serial Monitor.
Serial.begin(115200);
Serial.println("Default Serial port, not going to the Serial Monitor.");
}
void loop()
{
if(Serial2.available() > 0)
{
Serial2.print("You typed: ");
while(Serial2.available() > 0)
{
int inChar = Serial2.read();
if(isprint(inChar))
Serial2.print((char)inChar);
}
Serial2.println();
}
delay(10);
}