Reconnecting USB makes batch files not work

Hello!

I have a code that reads a letter from serial port and configures pin outputs accordingly. When I upload it to Arduino Nano and use serial monitor - all works. If I manually reset Arduino by pressing a button - it works. If I send letters via batch file - it works.

However, if I reconnect the USB cable Serial Monitor still works, but Batch files just make the board restart.

I want batch files to work regardless of how many times I reconnect USB. Any ideas?

Your topic has been moved. Please do not post in "Uncategorized"; see the sticky topics in https://forum.arduino.cc/c/using-arduino/uncategorized/184.

That is because your computer is enumerating the USB ports. You need to change it on the PC side.

Hi @perezver_mani. The classic Nano board has an auto-reset circuit that causes the board to reset whenever its serial port is opened.

So it is expected that the board will reset when a batch file opens its serial port. As @gilshultz mentioned, it is theoretically possible to avoid this if you can control the technical details of how the port is opened by your batch file. The reset is triggered when the computer asserts the DTR signal. If you can configure the way the port is opened so that the signal is not asserted then opening the port will not reset the board.

Alternatively, you can use the hardware solution of disabling the reset circuit on the board. This can be done by connecting a capacitor with a value somewhere in the ballpark of 10 uF between the reset and ground pins of the Nano. If you do that, you must remember to remove the capacitor when you are uploading new sketches to the board because the board must be reset at the right point during the upload process and the auto-reset circuit normally takes care of that for you.

However, I'm wondering if it is truly necessary to avoid the reset in order to solve your problem since you seem to be indicating that Serial Monitor (which also resets the board when it is first opened) and manually resetting the board does not cause the unspecified problem.

So if you want effective assistance, I think it will be necessary for you to provide us with more information:

Your sketch

Please post your full sketch.

I'll provide instructions you can follow to do that:

  1. Select Tools > Auto Format from the Arduino IDE menus.
    This is done to make the code easier for us to read.
  2. Select Edit > Copy for Forum (Markdown) from the Arduino IDE menus.
  3. In a forum reply here, click on the post composer field.
  4. Press the Ctrl+V keyboard shortcut.
    This will paste the sketch to the post composer.
  5. Move the cursor outside of the code block markup before you add any additional text to your reply.
  6. Repeat the above process if your sketch has multiple tabs.

When your code requires a library that's not pre-installed in "Arduino Cloud Editor", please post a link to where you downloaded that library from.

Your batch file

Please post your batch file:

  1. Copy the text of the batch file.
  2. Click the <CODE/> icon on the post composer toolbar.
    This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
  3. Press the Ctrl+V keyboard shortcut.
    This will paste the output into the code block.
  4. Move the cursor outside of the code block markup before you add any additional text to your reply.

Description of problem

Please also provide a detailed description of the problem you are having, including:

  • What did you do?
  • What were the results you expected from doing that thing?
  • What were the results you observed that did not match your expectations?

Make sure to include the full and exact text of any error or warning messages you might have encountered.

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