Serial Monitor loses connection intermittently


I have a relatively complex program running on an Arduino Mega 2560, using about 75% of the IO pins, mostly digital. The hardware that connects to this unit includes a custom PCBA with buttons, LEDs and an OLED screen and I am using the very cool u8g2 library to drive the screen.

In our last internal release of this code, we're now seeing a situation where some of the time the serial monitor (native to the IDE) stops responding. It will clunk out in the middle of a Serial.print statement and the only way to recover it is a new upload, or closing and restarting the serial monitor.

I am slowly removing the code from the most recent release to try to see if I can isolate what might have caused this. Latest rev is using only 26% of program storage space and 65% of dynamic memory. I am using the F macro for all serial print and u8g2 print statements that have static text. I have just one String variable, and removing that does not change any behavior that I can tell.

I would love some advice here on how to make this more of a specific effort versus what I feel is just some blind troubleshooting.


How do you know it's only the serial that is stopping?

Thank you for the quick response! I base it on: The unit is still running, i.e., the display interaction, the buttons, LEDs, oscilloscope on the outputs. So "to the customer" there is no obvious problem here, but I have enough battle scars to know that there may be an issue here that I am not seeing besides the serial monitor no longer responding.

Are you sending a lot of data via the serial, if so is it your machine that is loading up. Did you try putting the scope on the serial output?

Thanks for the quick reply! I haven't probed the serial output. I am not sending a lot of data, if I compare to the amount of instrumentation I have used off and on since starting this project (9 months ago). I have had more output in the past, i.e., screenshot data from the display library for example. So I don't think a change in volume is the culprit.

That will tell you if the unit quit outputting or you quit receiving the data.

Connect using Putty or some other terminal emulator to make sure it's not serial monitor related.

Yep, I started doing that as well. So far I cannot reproduce the problem on PuTTY, but it's not been a lot of cycles. Thanks.

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