Arduino IDE Serial Port Issues

Getting back to developing on Arduinos recently after a bit of a gap, I was immediately hit by problems uploading code onto my Arduino boards. Obviously this was very frustrating when I’d just spent time writing the sketches and was very keen to see if they actually worked. There are a couple of Arduino IDE serial port issues that can be behind these problems, so I decided to take some time out to try to get to the bottom of them. And hopefully save myself a lot of time in the future.

There are a load of Arduino board types to choose from. My collection includes only the Uno, Leonardo and Nano – so not a comprehensive selection, but you can only fix what’s in front of you! The two issues I’ve run across are detailed below:

Issue 1: Driver not recognised

The original Arduino Uno uses an Atmega16U2 chip for serial communications with the IDE. This chip is actually a proper microcontroller in its own right which might seem like overkill. One of the positive side-effects of this is that it is recognised fine by Windows. Running up the Windows Device Manager, this is what I see with an original Uno connected:

Arduino IDE serial port

Switching to the Leonardo, this board is based on the ATmega32u4 which has built-in USB serial comms. This removes the need for the secondary processor used in the Uno. When I plug my Leonardo in to the development machine, this is what I see in Windows Device Manager. Once again the Arduino is identified correctly:

All well and good so far.

Clones …

The genuine Arduino Nano uses an FTDI USB serial chip but unfortunately I don’t have one of these, so can’t verify what appear in Device Manager. All the Nanos I have are clones, and this is where it can all start to get a bit tricky.

While the clone boards are nominally the same as the official Arduino boards, many of them use the CH340G serial chip for their USB comms rather than the more sophisticated chips used on the official boards. That shouldn’t cause a problem if the driver is set up correctly on the development machine. What I see in Device Manager when I plug a Nano clone into my dev machine is this:

Arduino serial port

Not quite as specific as the (genuine) Uno and Leonardo, but Windows knows what it’s connected to, so it should work ok. I do have one clone Uno board as well – this identifies very similarly in Device Manager:

However, if the driver isn’t set up Device Manager will show something like this:

On my Windows 10/11 machines this appears to rectify itself pretty quicky and installs the driver automatically, assuming there’s an internet connection. In this case the line in Device Manager updates to the USB-SERIAL CH340 as above quite rapidly. However, on my old Windows 7 development laptop there is no automatic update so the message remains:

Note: the device also appears under “Other devices” rather than Ports (COM & LPT).

And to fix it:

If your machine hasn’t just done this itself, basically it’s just a simple driver install. Probably the best way to get the right driver is via an online search for “CH340G driver” for your particular Windows version. There is a very good tutorial on Sparkfun that also includes links for the driver download for Windows, Linux and Mac OSX.

As an aside, the Sparkfun tutorial includes instructions for installing the driver on Raspbian. I’d never thought of trying this, but how cool would it be to have your Arduino development environment running on a Raspberry Pi? (… well I think it would be!)

Issue 2: Port access denied

I ran across this error when I was updatng my stepper motor driver sketch to test my macro rail prototype a few days ago. When I compiled and tried to upload a sketch the Arduino IDE gave me something that looked like this:

Focussing on the bottom block at a slightly more readable size:

Now that “can’t open device” message is basically telling me that port com6 isn’t available, because something else has grabbed it for its own use. Very helpful considering nothing else running on my PC was using serial comms. The obvious solution is to move to another port – but guess what? I plug in to a diffferent USB port and get the same message, but with the new port number. Very annoying!

So how to fix it … First I ran up Windows Device Manager to find which port the Arduino or CH340 had been assigned to, then in the Arduino IDE checked that the correct port had been selected. The ports matched, so the next step was to find out which application has locked it.

I’m quite bad at keeping multiple apps open on my development machine, so when the “access denied” message came up, most of my commonly used apps were running. None of them were using serial ports as far as I could tell – but then what do I know when it comes to the inner workings of Windows.

Fixing it:

The highly sophisticated way to find the cuplrit was to shut down apps down one at a time and test the serial upload after each one. Eventually the upload worked, suggesting that the last app to be closed was at least partially responsible for the problem. In my case the one that made the difference was Spotify. That’s not always the case, however – after a computer restart and with Spotify running, I ran up the Arduino IDE and uploading to an Uno and a Nano both worked fine. Go figure!

The good news in this apparently random behaviour is that I can still listen to music on the computer while I’m doing Arduino development. The bad news is that the problem isn’t really fixed and I have no idea when it’s going to reappear, or which app is going to be responsible next time. If and when I encounter it again I’ll update this post …

Leave a Reply

Your email address will not be published. Required fields are marked *