user27383: I have coded arduino for DHT11 which used to print humidity in first and temperature in second line. But some times when I open SerialPort I get absurd data.

user4143: You can't.
The data you are seeing has already been sent by the previous execution of the sketch before the main MCU was reset. That data resides in a small buffer within the USB interface chip (or even within the USB CDC/ACM / USB UART driver itself, depending on your OS) to which you have no access.
You just have to ignore that data. The simplest way is to put a marker at the start of your program to indicate that whatever is receiving the data should start its receiving from this point on. Something like:
Serial.println();
Serial.println("START");


27383: <p>I have coded arduino for DHT11 which used to print humidity in first and temperature in second line. But some times when I open SerialPort I get absurd data.<a href="https://i.stack.imgur.com/oDeKQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oDeKQ.png" alt="enter image description here"></a></p>
 4143: <p>You can't.</p>

<p>The data you are seeing has already been sent by the previous execution of the sketch before the main MCU was reset. That data resides in a small buffer within the USB interface chip (or even within the USB CDC/ACM / USB UART driver itself, depending on your OS) to which you have no access.</p>

<p>You just have to ignore that data. The simplest way is to put a marker at the start of your program to indicate that whatever is receiving the data should start its receiving from this point on. Something like:</p>

<pre><code>Serial.println();
Serial.println("START");
</code></pre>
