Due serial coms not working with serial monitor not open


So i'm working on a very calculation and time sensitive project, it is important for things to happen as quickly as possible. Because of this I am trying to learn how to use the native USB port to upload my codes and read serial data with the due.

I have run into several problems.

1: When I upload a very simple code which just increments a counter and SerialUSB.println(counter); to print the counter value, the counter does not start at zero, it starts at 19 some times, it also starts in the 20s somewhere some times. It seems random. If I upload the exact same code using the programming port it starts at zero correctly. I will attach my code below.

2: For both the programming and native ports the arduino does not send serial data while the serial monitor is not open. I have used both a winforms app I created, and a free software called 'Free device monitoring studio' to try to read the data that the arduino should be sending, but they both get nothing when the serial monitor is closed. As soon as I open the serial monitor however, it shows the serial communication resume.

3: This probably has something to do with #2, but when ever I close and re-open the serial monitor, the program I am running resets (or at least some kind of memory is reset) because the counter program mentioned above resets to zero when I close and then re-open the serial monitor.

Does anyone have an explanation for this? I would like to have the arduino running by itself and sending serial data without having the arduino IDE's serial monitor open.

int counter=0;
void setup() 

void loop() 

Hi Soronemus,

I had also faced issue similar to you on the Native USB Port.

I found that it takes approximately 4500 msecs for the loop() to run when programmed for Native USB Port. So I added a delay of 5000 msecs in setup(). So now I am not missing any of my prints.

I do not know what causes so much of delay.

But if you do the below experiement then you can understand:

Open the Arduino IDE and flash your code for Native USB Port. Now open the serial port (you will see /dev/ttyACM* in Ubuntu or /dev/COM* in WIndows with Native USB Port written in brackets). Now press RESET Button on the Arduino. Immediately see the serial port lists. You will not be able to see the Native USB Port enumerated there. It will take almost 4-5 seconds for the serial port to get detected.

If anybody knows the reason then please do let me know.

Thanks, Sunny