I have an Arduino Uno connected through USB to my Ubuntu PC (one USB hub in between).

I run a program that communicate through serial and use then the port /dev/ttyACM0

It works well though not stable, the Arduino, every now and then, suddenly change to \dev\ttyACM1, making the code crash. I can change the port in my code and restart. It will then run well until the Arduino decides to go back to /dev/ttyACM0.

I can't figure out the reason, and even less the solution. Would there be any help here?

  • It sounds like you are saying that your Ubuntu PC is the one that is changing ports randomly. That is also common on Windows PCs. You should know that is a function of the PC, and not of the Arduino. I don't know any way of preventing that in Windows, and I don't have any experience with Ubuntu. But if you think this is an Arduino problem, you may have asked the wrong question. – Richard Crowley Jun 24 '16 at 4:57
  • OK, maybe I'll ask on Ubuntu forum too :) thanks – Memes Jun 24 '16 at 4:58
  • The proper answer to this would be to write the code so that it can handle port changes. – SomeoneSomewhereSupportsMonica Jun 24 '16 at 4:59
  • 2
    you should be able to set a udev rule for this. I don't this question is a fit for this site, this is an OS problem. – efox29 Jun 24 '16 at 5:55
  • 1
    \dev\ttyACM1 is a typo? and yes "udev" is the way to do this. Here is an example creating a softlink; playground.arduino.cc/Linux/Udev – Rinzwind Jun 24 '16 at 7:20

Different cases can happen :

  1. The Arduino gets a new USB port each time it is connected. In that case, the solution is to create a symlink for the connection. This is done using udev.
  2. The Arduino randomly changes USB port, without being physically unplugged or the computer to be rebooted. Usage of udev will as well help but further debugging is necessary to understand why the Arduino disconnects in the first place. using udev rule might be enough to workaround the problem but might as well not be enough (for instance if the Arduino is hung after the disconnection happens).
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.