Skip to content

HardwareSerial esp32-Wrover-kit Uart2 #4835

@francescot92

Description

@francescot92

hi,
I try to use UART2 of the esp32-Wrover-E with Arduino IDE. i know that the UART0 (pin 3 RX pin 1 TX) is for programing UART1(pin 9 RX pin 10 TX) for flash and UART2 (pin 16 RX and pin 17 TX) is free, but in this case these pins (16 and 17) are used to PSRAM.

From datasheet any pins can be used for the UART throuth the library HardwareSerial.h but it seem not work.

i try to communicate two micro throuth UART. i show you the sketch:

this a part of HardwareSerial.cpp:

void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, int8_t txPin, bool invert, unsigned long timeout_ms)
{
if(0 > _uart_nr || _uart_nr > 2) {
log_e("Serial number is invalid, please use 0, 1 or 2");
return;
}
if(_uart) {
end();
}
if(_uart_nr == 0 && rxPin < 0 && txPin < 0) {
rxPin = 3;
txPin = 1;
}
if(_uart_nr == 1 && rxPin < 0 && txPin < 0) {
rxPin = RX1; //RX1
txPin = TX1; //TX1
}
if(_uart_nr == 2 && rxPin < 0 && txPin < 0) {
rxPin = 33; // pin used to UART2
txPin = 32;
}

my sketch:
#include <HardwareSerial.h>

HardwareSerial myUart(2);

String messaggio = "NULL";
char terminatore = '\r';

void setup()
{
// Setup Serial connection:
Serial.begin(115200);
myUart.begin(115200);
delay(1000);
}

void loop
{
if(myUart.available()>0)
{
Serial.print("available:ok\n");
messaggio = Serial2.readStringUntil(terminatore);
}
......

I don’t get anything.
Can you help me??

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: StaleIssue is stale stage (outdated/stuck)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions