Serial reading twice?

Hi, I am new to Arduino. I am using the Arduino MKR Zero board and trying to send and receive data to and from the board. Even though I am sending data only once it appears that my board is receiving it twice. Below is the simple code to test the serial data transfer:

void setup() {

void loop() {

  if(Serial.available() > 0){

    // Reading data
    char receivedChar =;

    // printing data

    // Making sure no data is left in Serial Input Buffer
    while(Serial.available() > 0){

When I send a character 'g' I always receive
in my Serial Monitor in all types, i.e. in 'No Line Ending', 'Newline', 'Carriage Return' and 'Both NL & CR'.

I tried reading about it but on all posts, everyone always mentions the to take care of Newline to get rid of such a problem. But I am doing it and still, I am getting two identical replies when I should be getting only one.

Also, to flush out the input buffer (as Serial.flush() is completely useless for this) I am adding the last part in my code, but this is also of no help. I am quite sure I am missing a small detail somewhere but I am unable to figure out where, can someone please help me regarding this?

The above problem was with Arduino Web IDE. When I tried with Putty, Arduino IDE installed on my computer and Qt's Serial Communication and the problem wasn't there. I had to update my installed Arduino IDE and now the problem has also disappeared from Arduino Web IDE. I think it had something to do with installed Arduino drivers which got updated when I opened the installed Arduino IDE.

when i enter "1234", i get the following


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