Serial.available is always 0 when using Serial.print

Hello guys,

Im facing the issue that Serial.available() is always 0 when I'm using Serial.print.
The search says it might be a known issue, but I do not found any solution that fits for me.

If I'm using the following simple code "serial receive buffer" supposed to have a value, right? Serial.print("Hello, World!"); does fill the buffer?

But Serial.available() is always 0? Do you know why?
Im using Arudino IDE 2.2.1 with ESP32C3.

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

void loop() {

  Serial.print("Hello, World!");
  
  delay(1000);

  if (Serial.available() == 0) {
    // Will never be reached.
  }
}

BR

Serial.available() returns the number of bytes in the receive buffer, not the send buffer

If you look at the value returned by Serial.print() it will tell you how many bytes were printed by the command

Serial.print fills the send buffer, but Serial.available checks for bytes in the receive buffer.

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