communicating two esp32 via serial2 / 1

bobfrit
Posts: 2
Joined: Mon Jul 08, 2019 3:48 pm

communicating two esp32 via serial2 / 1

Postby bobfrit » Fri Aug 09, 2019 3:43 pm

ive been trying to get serial2 to work on my esp32-dev-kitc-v4 using arduino ide, my goal it to have two esp32 communicate to each other via serial2 and/or serial1 to then print it on serial to view it on my com ports. unfortunately it seems that no data is being transmited nor read from serial2.
ive tried the following but with no result
[Codebox]
#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
while (Serial2.available()) {
Serial.print(char(Serial2.read()));
}
}[/Codebox]
i was streaming to the rx2 at the same baud of 9600 from my other esp32 module from its tx0 which i know works.

ive also tried with adding
[Codebox]
#include "HardwareSerial.h"
HardwareSerial Serial2(2);
[/Codebox]
but i get an error saying
[Codebox]
Arduino: 1.8.9 (Windows 10), Board: "ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, None"

C:\Users\chc\AppData\Local\Temp\arduino_cache_68269\core\core_a1f5fc68bc90c0a52cdc3914a0c9afc7.a(HardwareSerial.cpp.o):(.bss.Serial2+0x0): multiple definition of `Serial2'

sketch\sketch_aug09a.ino.cpp.o:(.bss.Serial2+0x0): first defined here

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board ESP32 Dev Module.

[/Codebox]

i would like to know how i can get serial2 to work.

TheMosFet
Posts: 3
Joined: Wed Aug 14, 2019 8:54 pm

Re: communicating two esp32 via serial2 / 1

Postby TheMosFet » Thu Aug 22, 2019 4:44 am

I have a project connecting to a display via uart and to a 328p, and have been experiencing the same issue. Originally, I was using the third (uart /serial 2) for display and it functioned well. I managed to get comms with uno on the second (serial 1) port to work, but after and update... It receives nothing on the rx line. Tried multiple pin assignments. not here to jack to jack, but I see many people consider this closed issue. It isn't. He's not crazy.

Who is online

Users browsing this forum: No registered users and 79 guests