Serial.parseInt avoid the escape char \n

I’m having some trouble to understand how to avoid the new line character that is 0 when is parsed to int.

I wrote this code to ask to the user the configuration values during the setup function:

typedef struct {

  String name;
  int value;
  String message;
  
} grow_detail;

void setup() {

  Serial.begin(9600);

  grow_detail defaults[] = {
    {"TEMPERATURE_MIN", 0, "What you want as minimum Temperature? "},
    {"HUMIDITY_MIN", 0, "What you want as minimum Humidity? "}
  };

  for( int i=0; i < ( sizeof(defaults) / sizeof(grow_detail) ); i++ ) {

    Serial.print( defaults[i].message );
   
    while( defaults[i].value == 0 ) {

      if( Serial.available() > 0 ) {

        defaults[i].value = Serial.parseInt();
        Serial.println( defaults[i].value );
       
      }

    }
    
  }

}

But when it run the second question it takes 0 automatically when is called parseInt, how can I avoid this?

A example output that explain the problem:

What you want as minimum Temperature? 25
What you want as minimum Humidity? 0
32

commonuser: But when it run the second question it takes 0 automatically when is called parseInt, how can I avoid this?

Select "No Line Ending" in the serial monitor. At that point, it will use the default timeout in parseInt() which may annoy you.

you can modify the timeout with Serial.setTimeout().

The examples in Serial Input Basics are non-blocking, unlike Serial.parseInt(). There is also a parse example.

...R