Serial monitor issue

Hello, not sure if this is the right place to ask...

Is there any limit how how much the Serial Monitor can handle?

I have a Mega 2560 board that print one line with data every 5th second. And it can keep on doing so for days. But I noticed that several time I do not get any data in the monitor and some time later I loose the USB interface on the PC. I have to restart the PC to get it back.

The sketch/controller is doing fine all the time.

When I removed the code that print out data to the serial interface every 5th second, the problem is gone.

Did you try to change the serial monitor to another Serial terminal?
Does your PC go to sleep ?

J-M-L:
Did you try to change the serial monitor to another Serial terminal?
Does your PC go to sleep ?

No, I have not. Not sure what you mean by "another Serial terminal". Do you mean using a different program on the PC, like Putty?

And no, my PC run 24/7/365. It never sleep.

I have checked "Show timestamp" in the serial monitor. And the last lines always contain "timestamp ->" and nothing more.

thehardwareman:
I have a Mega 2560 board that print one line with data every 5th second. And it can keep on doing so for days. But I noticed that several time I do not get any data in the monitor and some time later I loose the USB interface on the PC. I have to restart the PC to get it back.

What do you mean by "I loose the USB interface"? In the IDE (which version)? In the operating system (which one)? After how many characters / lines / messages / minutes do you get the problem?

thehardwareman:
No, I have not. Not sure what you mean by "another Serial terminal". Do you mean using a different program on the PC, like Putty?

I think that that was meant. I'm using Windows and RealTerm for those situations.

Yes I meant using a different application, possibly something that has the option to log the incoming stream directly to a file for example

If that does not fail then that could point at an issue with Arduino IDE’s terminal being faulty

Other issue could be a memory challenge on your Arduino if you abuse the Strings class to do the printing and run out of memory

sterretje:
What do you mean by "I loose the USB interface"? In the IDE (which version)? In the operating system (which one)? After how many characters / lines / messages / minutes do you get the problem?
I think that that was meant. I'm using Windows and RealTerm for those situations.

IDE version 1.8.12. Windows 7 Ultimate.

I first start loosing text from the Arduino (only the timestamp is shown as if I did a "Serial.println("")'.

Then I loose the USB interface and sometime the network connection (Internet).

When I disabled the logging lines that are printed every 5th second it works OK. The arduino (Mega 2560) can stay on for days printing logs every 5th second.

So for me it seems like there is a memory problem in the serial monitor that cause this problems. I'll try Realterm and see what happens.

You arduino should not be impacted by what happens on the PC side.
Can you see if the MEGA keeps on running even if the Serial terminal is dead ?
if the MEGA dies, it likely points at an issue in your code.

J-M-L:
You arduino should not be impacted by what happens on the PC side.
Can you see if the MEGA keeps on running even if the Serial terminal is dead ?
if the MEGA dies, it likely points at an issue in your code.

The mega just keep on going and going :slight_smile: It also use a WiFi module and it send data every minute - no problem.

The problem only occur when there is a lot of data (over time) to the serial monitor. Currently the Mega has been on for 4 days with minimum use of Serial.print and Serial.println. And the USB port is OK.

OK - but when you have heavy use of logging, does the MEGA crash ?
are you relying on the String class in your code ?

J-M-L:
OK - but when you have heavy use of logging, does the MEGA crash ?
are you relying on the String class in your code ?

The mega does not crash.
I use String class when doing http connection to a web-server. Does not seem cause any problems.

Did you try an alternate terminal program?

I did ask before, how much data are we talking about? What kind of time frame? Did I miss the answer?

sterretje:
Did you try an alternate terminal program?

I did ask before, how much data are we talking about? What kind of time frame? Did I miss the answer?

I have not tried it yet. The controller is in a test I do not want to interrupt. But I'll try that when the current test is done.

Output one line of data (70-80 chars each line) every 5th second. I addition there are other output too, but only a few lines during 24 hours.

What is connected to the Arduino ? If it is driving a significant load the regulator may shutdown and crash the Arduino out .

Also seeing the code might be useful , you may have something causing memory creep.

(Bear in mind when you restart the PC the Arduino is also reset )

The Mega has it's own power supply - 5V 3A. It work well if I disconnect the USB plug. There is a few LEDs, a 2004 display, a RTC and a WiFi module. An amp-meter show about 300 mA steady load.

I know that restarting the serial monitor cause the Mega to restart.

"Is there any limit how how much the Serial Monitor can handle?"

There may be issues in the IDE where unbounded saving the input to the serial monitor can cause an IDE stall or lockup. In the past there were issues with orphan files being created by the IDE that resulted in creation of huge temporary files, but this may not be an issue now. Does the issue disappear when the serial monitor is not left open for extended amounts of time?

Today it has stopped even with small amount of ouput. Restarting the Mega did not help. I had to disconnect it from the PC and connect it again. Then it worked.

I use String a few places, but changed that to use char[] instead. I'll let it run for 4-5 days and see.

Put something in your code that will also blink an LED every so often. When things lock up, if the LED is still blinking, you can assume the code is still running and it isn't an issue with the board and the code.

zoomkat:
Put something in your code that will also blink an LED every so often.

But remember to make that delay-less else it tells you nothing.

It's easy just to take the stuff from blink without delay into any sketch. What I often do to keep things tidy is put blink without delay's loop stuff in a function called say proofOfLife() and call that from loop() of my actual sketch.

I already got a heart beat led that blink like heart beat and it works all the time. Also, I'm using a GET request to send data to a web server which send it to a MySQL server (should have used POST but the values are in the GET request), which also work fine. The update of the 2004 LCD display works fine.

And there are no delay() in the code except in the setup() function. I'm an timed event handler that calls different function based on millis and how often each function should be called.

You should try with a different terminal application. If that does not crash that will tell you clearly it’s IDE related