espressif / arduino-esp32

Arduino core for the ESP32
GNU Lesser General Public License v2.1
13.08k stars 7.31k forks source link

Strange issue with Serial2 #650

Closed viktor1970 closed 4 years ago

viktor1970 commented 6 years ago

Hardware:

Board: DOIT DevKit V1 Core Installation/update date: 20/sep/2017 IDE name: Arduino IDE Flash Frequency: 80Mhz Upload Speed: 921600

Description:

Hallo, I've a strange issue with Serial2: there's a lot of garbage sent. Here's the screenshot

On 1st loop the data (Nextion display codes) are sent correctly ("n1.val=5" and "dim=99", both with 3 0xFF as terminator); starting from second loop there's only garbage (exceps when val=17, but there's garbage too).

Then I made only this change: HardwareSerial Seriale(1); Leaving same pins and (of course) same code, and it works perfectly.

There's some issue with Serial2?

Best regards

Sketch:


#include <Wire.h>
#include <Nextion.h>

HardwareSerial Seriale(2);
Nextion nex(Seriale, true);

unsigned long tm1,tm2=5;;
char bf[20];

void setup() {
  Seriale.begin(38400,SERIAL_8N1,26,27);
  Serial.begin(115200);
  tm1=millis();
}

void loop() {
 if((millis()-tm1)>2000)
 {
  Serial.printf("num: %d",tm2);
  sprintf(bf,"n1.val=%d",tm2++);
  nex.sendCommand(bf);
  if(tm2%2) Seriale.print("dim=2"); else Seriale.print("dim=99");
  Seriale.write(0xFF);
  Seriale.write(0xFF);
  Seriale.write(0xFF);
  tm1=millis();
 }
}```

### Debug Messages:

No crashes

me-no-dev commented 6 years ago

There is... it's not quite clear to me what, but I am about to change the UART driver so it should get better

me-no-dev commented 6 years ago

Please pull the latest changes and report :) Thanks!

viktor1970 commented 6 years ago

Hallo, I installed the lastest changes but nothing changed: This is what happens when using Serial(1): esp32_serial1 The correct data "n1.val=5" plus 3 0xFF are sent and 01 FF FF FF code received.

When using Serial(2): esp32_serial2

Only garbage data on TX, nothing on RX. I tried to use native pins too, same result

Now I'll try with another ESP32 board.

Regards

viktor1970 commented 6 years ago

I tried another ESP32, both with native and other pins. No changes.

Regards

everslick commented 6 years ago

@viktor1970 Is this issue still unresolved for you? Can we close this?

EUNGJU-S commented 6 years ago

Hello, @everslick I have same problem. Is this issue resolved ? When I using Hardware Serial (2) sometimes It does not works correctly. And I just changed Serial (2) to Serial (1) It is fine. But I hope using more Serial port on ESP32 stably.

kolive360 commented 5 years ago

I try whit the Serial1 and work, but is fool

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 4 years ago

This stale issue has been automatically closed. Thank you for your contributions.