About "Ardino serial.print() by ESP32"

UART in your ESP32

“U0TXD and U0RXD”

I found “U1TXD and U1RXD”.

Please tell me how to transfer each port of UART in Ardino serial print.

Example From two channels Seriarl. I want to exchange communication with Print.

Example 1 First channel. … I would like to use it for writing Ardino.

Second channel. …

I want to connect the device to the ESP32 and exchange them by communication.

You might have a look at this:

https://github.com/G6EJD/ESP32-Using-Ha … rial-Ports

Even if this searches

I couldn’t find it.

thank you very much.

I’ll try it immediately.

Edit

As a result of executing

The following problem occurred.

Q

Communication between ESP32-WROOM-32 and ESP32-WROOM-32D

U2TX IO17

U2RX IO16

Wired each other.

And I wrote the following program.

TX only outputs waveform

It does not come out correctly.

Both speed and waveform voltage are different

Of course, I do not receive it either.

The problem is that you connect it directly to the wiring?

No pull-up resistor or pull-down resistor is connected.

Or is it a program?

program

Both wrote the same thing.

/*

  • There are three serial ports on the ESP known as U0UXD, U1UXD and U2UXD.

  • U0UXD is used to communicate with the ESP32 for programming and during reset/boot.

  • U1UXD is unused and can be used for your projects. Some boards use this port for SPI Flash access though

  • U2UXD is unused and can be used for your projects.

*/

#define RXD2 16

#define TXD2 17

void setup() {

// Note the format for setting a serial port is as follows: Serial2.begin(baud-rate, protocol, RX pin, TX pin);

Serial.begin(115200);

//Serial1.begin(9600, SERIAL_8N1, RXD2, TXD2);

Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);

Serial.println("Serial Txd is on pin: "+String(TX));

Serial.println("Serial Rxd is on pin: "+String(RX));

}

void loop() { //Choose Serial1 or Serial2 as required

Serial2.write(“12”);

while (Serial2.available()) {

int a=Serial2.read();

Serial.print(a);

}

}

Edit the program you received on the support forum

When I moved it, it worked.

Communication failure has been cured.

Cause

Between devices that communicate

This is because the power supply (3.3V) and GND wiring were not common.

feedback

Besides

It is also necessary to note that you have to wire so that it becomes “Wiring at the intersection like RX-TX TX-RX”.

If you think about this and work

I think that the above program can be controlled by UART2.

Mysterious thing

When controlling Serial Write

Finally [Serial2.write(0)]; OR as shown in the control below

It doesn’t work properly.

This is because I am sending one character at a time

I think it will be [ Serial2.write(1);]

Duplicate letters or send strange numbers.

why?

PS

We are [ Serial2.write(-);] as the transmission content

I think it specifies the number of bytes to send.

In that case, one character should be sent as one byte.

It’s different, so I was curious and asked a question.

Sample program

= =

for (int i = 0; i <sendstr.length (); i ++) {

Serial2.write (sendstr.charAt (i));

Serial.print (sendstr.charAt (i));

delay (500);

}

Serial2.write (0);

Write when Serial2.write (); is set to 0

Sometimes it’s strange to set Serial2.write (); to 1.

Transfer is not possible if Serial2.write (); is set to 2.

Feedback This was probably due to the following:

I think.

Guess

Because the reading side judges “0” as follows

If there is no “0”, it is considered that it was not read correctly.

if (Serial2.available ()> 0)

{

char inChar = char (Serial2.read ());

buffA [counter] = inChar;

counter ++;

// buffA [counter] = 0; // → Originally this is necessary, forget to write

delay (100);

if (inChar ==‘\ 0’) {} // Completion judgment Probably to see this Serial2.Write (0);

Is guessed.