Sub topic 7
Selecting the Serial Port
Assume you have installed the Arduino IDE, connected a supported Arduino board with a USB data cable, and selected the matching board under Tools > Board. This chapter focuses on choosing the port that lets the IDE communicate with that board.
What a serial port is
A serial port is a communication endpoint created by your operating system for a connected device. The Arduino IDE uses this endpoint to send a compiled sketch to the board and to receive messages from it.
The port name depends on your operating system and board:
| Operating system | Example port name | Common meaning |
|---|---|---|
| Windows | `COM3` | A numbered communication port |
| macOS | `/dev/cu.usbmodem1101` | A USB modem-style device |
| Linux | `/dev/ttyACM0` | An Arduino-compatible USB serial device |
The board and port are separate settings. The board tells the IDE how to compile the sketch. The port tells it where to send the compiled program.
Find the board's port
- Connect the board directly to your computer with the USB cable.
- Wait a few seconds for the operating system to detect it.
- Open the Arduino IDE.
- Open Tools > Port.
The connected board usually appears beside a port name. In Arduino IDE 2, you may also see the board and port selector near the top of the window.
If several ports appear, disconnect the Arduino and open the port list again. Note which entry disappears. Reconnect the board and select the entry that returns. This is a reliable way to identify the correct port.
Select and verify the port
Choose the port under Tools > Port, then try uploading a small sketch. The IDE uses the selected port during the upload process. If the upload succeeds, the port is correct.
A selected port can become invalid if you unplug the board, change USB sockets, or restart the computer. The operating system may assign a different name when you reconnect it. Always check the current port before uploading if the board has been moved.
The port can also be temporarily unavailable while another program is using it. The Serial Monitor, another Arduino IDE window, or a terminal program may hold the connection open. Close those programs and retry the upload.
When no port appears
Check these causes in order:
- Confirm that the board's power indicator is on.
- Try a different USB cable known to transfer data.
- Try another USB socket, preferably directly on the computer.
- Disconnect and reconnect the board.
- Restart the Arduino IDE.
- Check whether the board needs a USB driver.
- On Linux, check whether your user has permission to access serial devices.
Some compatible boards use a USB-to-serial chip that requires a manufacturer driver. The board may receive power before that driver is installed, so a lit power LED does not prove that communication is working.
On Linux, a port such as /dev/ttyACM0 may be visible but inaccessible. Adding your user to the system's serial-device group can fix this, but the exact group and command depend on the Linux distribution.
Port errors during upload
An error such as “avrdude: ser_open(): can't open device” usually means the selected port no longer exists, is busy, or cannot be accessed. Select the port again after reconnecting the board.
An error saying that the programmer is not responding can also result from choosing the wrong board, not only the wrong port. Recheck both settings before changing upload options.
Exercise
You see COM4 and COM7, but you do not know which one belongs to your Arduino. How can you identify it safely?
Show answer
Open the port list, disconnect the Arduino, and note which entry disappears. Reconnect the board and select the entry that returns.