ESP8266 - RS232 reading Issue

Hi, i've a ESP8266 with RS232 connected to RX - TX.

I need to get data from the RS232 Serial every X seconds,
but here a strange issue, sometimes it display datas, when I plug / unplug the Arduino to my Macbook it stops to display Serial data...

void setup() {
  Serial.end();
  Serial.begin(9600);
}

void loop() {
  
  
  unsigned long currentMillis = millis();
  if (currentMillis - lastRequestTime >= requestInterval) {
    
    if (Serial.available()) {
      String data = Serial.readStringUntil('\n'); 
      Serial.println(data);
    
    }
    lastRequestTime = currentMillis;
  }
}

Moved to Interfacing w/ Software on the Computer.... Please don't post in Uncategorised again.

ok thanks

True RS-232 signals are inverted UART signals at high bipolar voltage levels. What do you mean by "RS232"?

Where? Serial Monitor? Other terminal program?
If serial monitor, which version of the IDE?

I assume that you mean unplug/plug. It's possible that the file handle that points to the serial port becomes invalid after unplugging. If so, close the connection and open it again might do the trick.

In Serial Monitor, i noticed that by adding Serial.swap(15); it seems to work, but now I've the Serial Monitor full of Serial Data even if I comment Serial.println(data); and no other Serial.println is displayed

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.