Hi folk,
Perhaps this problem has been raised before but when searching the forum I couldn't find a similar entry.
I'm using Arduino-IDE v 2.3.4 (on Linux).
I know there is a new version available but I won't update to it (yet).
I'm trying to connect Arduino Nano32.
The Nano is using direct USB (no USB hub).
It has USB data cable.
I'm having trouble to establish a connection to the board.
The IDE is listing sometime a /dev/ttyACM0, sometime a /dev/ttys0 sometime /dev/ttyUSB0 and sometime 3-2.1.1 (Arduino nano ESP32, Arduino Nano ESP32),
but whatever I'm selecting, it is not able to upload the code and execute it.
Sometime it seems to be uploading the code completely but when I'm switching to the serial monitor it says "no device connected".
I tried this with the example code "Board_Identify" provided by the IDE.
Does anyone knows what the problem here is and how I can rectify it?
TIA
It sounds like you completed the upload, but you may now need to reconnect the NANO to the port currently used to run the sketch. Press the reset button to start the sketch.
Thanks for the reply.
the 'reboot doesn't help.
And why is the IDE switching (it seems randomly) between those different USB connections?
It doesn't makes sense.
It seems that the IDE is switching with each compile cycle between USB's, /dev/ttyS0 and /dev/ttyUSB0.
Perhaps I have to reset all my USB's on the Linux box (if that even is possible).
Which board do you have selected?
I didn't say reboot; I said reset, which is the button on the NANO that starts your sketch. As long as you use Serial in your sketch, you should see whatever messages your sketch outputs. I would add a line in Setup to say Serial Ready after a delay(500);
Here are the two identically named boards;s, pick the right one.
To prove it's not Linux, plug in another board like an UNO and run the Blink sketch.
You should have found the following, but just in case.
The changing names are actually the clue here - those entries are not all the same device:
- /dev/ttyACM0 is the Nano ESP32 itself when your sketch is running, because it uses native USB (CDC). This is the port Serial Monitor needs.
- The entry shown like a USB path / "Arduino Nano ESP32" in the port list during upload is the board in DFU/bootloader mode. Uploading uses that, not a serial port. When the upload finishes and the board resets, that entry disappears and the board reappears as /dev/ttyACM0, which is why the list seems to change with every compile and why Serial Monitor then says "no device connected" - it is still pointing at the old DFU entry. Reselect /dev/ttyACM0 in Tools > Port after the upload has finished.
- /dev/ttyS0 is almost certainly a built-in serial port on the Linux machine itself, nothing to do with the Nano - ignore it.
- /dev/ttyUSB0 would be a different USB-to-serial adapter (for example a CH340 or FTDI device) that is or was plugged in - also not the Nano ESP32 in its normal mode.
A reliable way to identify it on Linux: unplug the Nano, run ls /dev/ttyACM* /dev/ttyUSB*, plug it in, and run it again - the new ACM entry is your board. You can also look in /dev/serial/by-id/, where the Nano shows up with Arduino in its name, which stops the guesswork.
Two Linux-specific checks if /dev/ttyACM0 appears and then vanishes: make sure your user is in the dialout group (groups command in a terminal), and on Ubuntu-based systems check whether the brltty service is grabbing the device - it is a braille display service that is well known for snatching USB serial devices a few seconds after they are plugged in.
So the workflow is: select the DFU entry (or just the board) to upload, wait for it to finish and reset, then select /dev/ttyACM0 for Serial Monitor.
>danielbrooks8807
Thank you for your tip. It was very helpful.
After a few test it I can confirm that /dev/ttyACM0 is the way to go. It was just a bit confusing that the other entries also appeared but were useless.
I guess I learned a little lesson some background information about the Arduino IDE.
I'm just not sure whether this item could have been resolved a little bit better in IDE by the developer (or maybe its just a shortcoming in Linux. Wonder weather users in windows have the same experience?)
Thanks again
I'm not familiar with DFU.
In general uploads work by invoking the bootloader; for boards with DFU I think the board will switch to DFU mode.
This is done in one of two ways (DFU mode might work a little different)
- For boards with native USB (the processor provides the USB connectivity) the IDE issues a reset command by opening and closing the port using a baudrate of 1200 baud. Boards in this category are Leonardo, Micro and most newer boards). Your Nano ESP32 also falls in this category also switching to DFU mode might work differently.
- For boards that have a dedicated serial-to-usb converter (classic Nano, Mega, Uno) opening the port invokes the bootloader by asserting the DTR signal.
For (2) the port does not change when the upload starts; ttyUSB0 stays ttyUSB0.
For (1) the port changes when using Windows (e.g. from COM4 to COM5) and back after the upload. Under Linux the port does not change; e.g. if your board is recognised as tyACM0 during normal use it will stay ttyACM0. However if you run dmesg -w in a terminal you will see that ttyACM0 disappears for a short while and (for the boards that I mentioned under (1)) it will appear again. If the board is in DFU mode ttyACM0 might not come back till the board leaves DFU mode; I do not know.
It seems that the situation has been stabilized.
When using an Arduino Nano ESP32, it's using ttyACMO, when using a Wemos D1 mini (8266) its using ttyUSB0.
When I keep that port (and not switching around) it is uploading fine now.
It still seems that when I have two sketches open (with different boards), the IDE might get confused. It can't distinguish ('detect') in which IDE I am currently working and would use that board setting.
Overall I would say the problem has been resolved.
Many thanks for the detailed responses that allowed me to a look little bit 'behind the scene' of the IDE/USB.
Thanks.