Prevent USB serial connection from restarting MEGA

I have developed an application using Feather Mo LoRa + DHT20 + RTD sensors
to wirelessly measure humidity and temperatures.
The "server" or aggregator is a MEGA + LoRa module/chip

These have been powered and connected via USB and I use two concurrent IDEs
to program/debug both client and server nodes
I have now developed USB-free operation...
The MEGA is powered by a 9V adapter into its power plug
The Feather M0 (SAMD21) and powered by a Lipo battery
I have incorporated low power "sleeping" between hourly readings to maximize battery life.

I notice now that the MEGA server is running and providing data to the telemetry system.
When I connect the USB in otder to monitor/interact with the server application,
the system appears to restart/reboot - all data is cleared and there is a period of
re-normalization...
What gives with that ??
I expect that since server power is being supplied by a power supply,
the USB connection should have no impact on the running server application.
I should be able to connect via USB serial, examine the operating status or
perform some adjustments and then disconnect
Some ideas as to the cause...
The transition between power-supply power and USB power could be causing a restart ?
Some quirky setting "must be happening"

It is by design that the Arduino resets when the PC opens the serial port

A possible solution is to use a USB to serial cable (FTDI cable - USB-ttl cable) connected directly to pins 0 and 1

There are other options documented on the internet like

(First random Google hit)

1 Like

3rd party terminal program often allow you to disable DTR and RTS when the port is opened; those signals cause the reset of the Arduino.

The most flexible way of solving this is to cut the jumper on the board "Reset EN" and then it will no longer reset when you connect. If you attach a switch to each side of the jumper after cutting it. You can put the switch in two modes: 1 - connection is made and the board will reset - use this for programming your board. 2 - connection is broken and the board will not reset - use this for normal operation when you want to connect and view data.

Kewl... Thank you very much for that precise concise explanation.

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