starting the serial monitor from within the sketch

I've hunted for a solution to the above but can only find references the starting the serial monitor after uploading a sketch.

I auto run a 54MB sketch every day at 06:30 on a Windows 7 computer that is connected to a Mega 2560 over USB.

I would like the serial monitor to start at the same time & output to the computer screen where I can check it later in the morning.

If this isn't possible using the IDE built in serial monitor is there a better serial terminal for Windows I could use that would allow me to perform this operation.

I'm a newbie so the suggestions need to be fairly simple

The Arduino cannot start anything on a PC. You must have a program on the PC that communicates with the Arduino. You should also be aware that when a PC program opens the serial port to connect to an Uno or Mega the Arduino resets. If that is a problem you would have to take steps to prevent it.

...R

I auto run a 54MB sketch

?

Robin2: If that is a problem you would have to take steps to prevent it.

If using a Mega, only Serial port 0 will reset the arduino.

You can easily create a custom program on your computer that will open the serial port to communicate with the arduino and do whatever you want with whatever data. I recommend C# because it's easy to learn and use, also very powerful and well documented.

guix: I recommend C# because it's easy to learn and use, also very powerful and well documented.

I like Python which is also simple to learn and use and, unlike C#, runs on Windows, Mac and Linux.

...R

I’m not sure I made myself clear; my apologies.

Normally, clicking on the serial monitor button from a running sketch would start the serial monitor running.
I assume this manual action of clicking the serial monitor button calls a piece of code so why can’t this be done from within the sketch?

As mentioned earlier, I’m no programmer so suggestions need to be kept simple :slight_smile:

Rather than doing this manually @ 06:30 is there a way to do this automatically from another serial terminal program that is already running under Windows 7?

I know I could just leave the sketch & serial monitor running 24/7 but I’ve found that the output text file from the serial monitor truncates (I assume because of size limitations of the file imposed by IDE), cutting off the earlier part of the file as the file grows in size.

❝I auto run a 54MB sketch ?

This means I start the Mega 2560 @ 06:30 using a time switch to turn on its psu. The computer is turned on later manually.
Obviously, to achieve the required action above I would leave the computer on 24/7

Robin2: I like Python which is also simple to learn and use and, unlike C#, runs on Windows, Mac and Linux.

...R

Agreed, proprietry languages are a millstone round everyone's neck in the end. I'd always always look for a way to avoid lock-in if at all possible.

I assume this manual action of clicking the serial monitor button calls a piece of code

It does.

so why can't this be done from within the sketch?

Because the code that is monitoring the icon is not running on the Arduino AND the code executed in response to pressing the icon in not Arduino code.

dominator99: Normally, clicking on the serial monitor button from a running sketch would start the serial monitor running.

How can you click on the serial monitor button from a running sketch ? If you really believe you can do this please post the Arduino code that does it.

@PaulS has it correct.

...R