Relation between delay and baud rate for Serial

Hi guys,

I have my NodeMCU v3 connected a serial port (module, Raspberry pi,...) where I can read the text sent by Arduino.
Here is the code:

unsigned long lastCharTime = 0;
#define BAUD 38400
void setup() {
  Serial.begin(BAUD);     // for debug only
  Serial1.begin(BAUD);
}
 
void loop(){  
  if(millis() - lastCharTime > 10000){
     Serial1.println("hello world");
     Serial1.flush();
     lastCharTime = millis();
     Serial.println("Sent..");
  }
  //delay(1);
}

But I got some weird characters:

kello world
kello0world
hunlo,worleM�
oumoo�wo{ow��

The Baud is same on both sides and using different baud do not solve the problem.
But I notice when I add delay (best 1ms) on loop function I receive only 10% of the time undesired characters on message, and 100% without delay.
Using Serial1.flush() or not do not change nothing.

Why delay affect the serial writing if things in Arduino happen synchronously?
How to avoid those weird characters?

Thanks

bits flip --> you have noise on the line. Use shorter cables/shielded cables/reduce baud rate ...

did you join GNDs too?

I was thinking about the female jumpers I'm using may be the problem. So now I just solder male jumpers directly on it but still same problem.

No i did not use GND only TX .

add GND - it's needed for both device to agree upon what 0 and 1 are (and protect your Rx pins from possible seing an over voltage)

I remember reading the article provided by @PerryBebbington, which may make sens in my case but I tested then it just stop receiving message.
The two devices have separated power source (ok not really, all are connected to different USB port but same PC).

you need it. if it does not work your problem is elsewhere, but you do need Rx to Tx and GND to GND (with compatible voltage from Rx to Tx)

Yes I thing you are right, the problem was missing GND.
Once I used a different power source I got the reverse, now I do not receive any message anymore without GND and when I plugged the GND I started receiving message without any weird characters.
But common ground do not work if devices connected to same PC.

I have to remember "common ground"!

Thanks!

I am curious to see your receiver codes.