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;
}
}
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