Serial reset without resetting program

Hi All,
I recently built a controller for my ceramics kiln. It controls the rate of temperature rise/fall and set points via a thermocouple and a solid state relay. After many iterations, everything works like a charm including output to an LCD. During troubleshooting, I added a bunch of data output via the serial monitor, so that I could have a record of what was going on at all times during the 12+ hour firing cycle, and could import data into microsoft excel for various graphing and manipulation. During my first two test firings, the serial monitor randomly dropped communication with the arduino and the only way to get it back was to unplug and re-plug in the usb port, which resets the arduino and restarts the whole firing cycle from the beginning. During the periods of no communication via the serial monitor, the Arduino continued to control the kiln properly and it properly output data to the LCD screen without interruption. It simply could not communicate with the computer anymore. In researching this issue, which others certainly have dealt with, I came across the following code that I was thinking about adding into my sketch:

 if(!Serial) {  //check if Serial is available... if not,
Serial.end();      // close serial port
delay(100);        //wait 100 millis
Serial.begin(9600); // reenable serial again
}

My question is: will this block of code reset the program that is running and thus interrupt my firing cycle, or will it reset the serial communication without resetting the whole program?

I am using an arduino UNO and a Macbook Air

Thanks :slight_smile:

The sketch that you have uploaded into UNO controls the kiln and sends some data to the OutputBox of the Serial Monitor. From your description, it appears that it is the Serial Monitor/PC that loses the existence of the USB/Virtual COM Port from its memory. In that case, it is my opinion that something has to be done at the PC side to avoid communication disruption of the said USB Port. You may try by shutting off all applications at the PC side except the Arduino application.

The UNO doesn't know anything about the USB connection. There is an external chip that converts the serial line of the UNO to USB communication. if ( Serial ) is always true on an UNO ( and if (!Serial) will never be true ) because the UNO doesn't recognize if the USB connection is broken.

It will not cause a reset. See further @MicroBahner's reply.

You can generally disable the auto-reset on the UNO by connecting a 10 uF electrolytic capacitor between Reset and Ground (+ side to Reset, - side to Ground). This absorbs the short negative-going pulse applied to the Reset line when Serial connects and prevents the reset. The Reset button will still work.

How do you power the Arduino Uno? @johnwasser's solution in post #6 will only work if you have an external power supply.

That is true... You can't disconnect the USB cable and keep the Arduino running if you are using USB for power.

Thanks all for the responses. I don't want to have to monitor the serial output for the whole duration of the kiln firing program, which is why I was hoping to find some automatic way of resetting the serial output when is breaks, but it sounds like the issue is on the PC side of things, so no dice...This is not really critical, it's just fun to have some data to play with, and since I track the on/off status of the relay, it lets me know when to start the kiln to best take advantage of cheaper power at night :slight_smile: I will make sure there are no extra programs running on the PC and will disable the wireless and anything else that I can and then will hope for the best! Thanks again for your thoughtful responses.

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