I am looking to make indicator lights for my computer to indicate things such as system load, IO usage, et cetera, using an Arduino and NeoPixels. I would like to just plug it into my computer, and have some custom software connect to it and send it the data it needs as my computer runs.

The part I am having trouble with is figuring out how to connect the Arduino to the computer in a way that is consistent in the long term.

I have had issues with the Arduino switching which /dev/ttyAMC* port it is assigned, so I looked for options other than the USB serial. The only other way seems to be USB, as that is the only common general purpose port these days.

This is where my problem lies. People don't seem to be doing this sort of thing, or at least they don't post about it.

The Teensy can act as a USB HID, but the raw HID feature hasn't been updated in almost a decade, the host side code is based on deprecated libraries, and it seems oriented more for Teensy to computer transfers.

There doesn't seem to be any consumer level USB interface chips available, either.

I found V-USB, which seems like a solution to my problems, in fact someone even used it to do basically what I want to do. However, I would still need to learn the library.

So, my question is what is the recommended way of interfacing between a computer and Arduino in the long term? Is USB support really necessary, or have I just overthought the entire thing?

  • You don't want to use V-USB if you can get an Arduino with a native USB interface (in which case you would use LUFA). – Ignacio Vazquez-Abrams May 28 '18 at 0:14
  • @IgnacioVazquez-Abrams By Arduino with a native USB do you mean something like the Arduino Zero/Due? – theJack May 28 '18 at 1:05
  • Those do have native USB, but they don't use LUFA. I was thinking more like the Leonardo or Pro Micro. – Ignacio Vazquez-Abrams May 28 '18 at 1:09
  • You should check out chipKIT - it has the best usb stack in the industry (I know, cus I wrote it ;) ) – Majenko May 28 '18 at 8:08
  • And this is me using it for something similar to what you want: hackingmajenkoblog.wordpress.com/2017/05/19/… – Majenko May 28 '18 at 8:11

I think the easiest option may be to keep the USB (ACM) link, so you don't have to do anything special on the Arduino, and try to figure out a way to identify the correct device on the computer side.

On Linux, providing consistent device names for specific peripherals is normally the job of udev. You could add your own udev rule to create a symbolic link for your Arduino every time you plug it in. Then, your custom software would always open /dev/neopixel-monitor, which would be a symlink to the proper /dev/ttyACMx device.

Actually, you may not need write your own rule. I took a look at the udev rules installed by default on my Ubuntu 16.04 and found a file named /lib/udev/rules.d/60-serial.rules meant to populate the /dev/serial/by-path/ and /dev/serial/by-id/ directories. Then I plugged in my Arduino Uno R3 and saw the symlink /dev/serial/by-id/usb-Arduino__www.arduino.cc__0043_93140364233351E00101-if00 automatically created, which right now points to ../../ttyACM0. In this name, 0043 is the USB device ID of the Uno, and the following alphanumeric sequence looks like a serial number. The if00 looks like an interface number, and may vary (it won't, se Majenko's comment). The link name should be a good way to uniquely identify that particular Arduino.

  • I have a file that makes /dev/boards/arduino/uno1 etc for all my boards. It's a rather massive file (I have a lot of boards), but it's very very useful. – Majenko May 28 '18 at 9:21
  • 1
    The rule for that one: ATTRS{idVendor}=="2341", ATTRS{idProduct}=="0001", ATTRS{serial}=="6493832323135111C0A1", KERNEL=="ttyACM*", MODE="0666", GROUP="plugdev", SYMLINK+="board/arduino/uno1" – Majenko May 28 '18 at 9:21
  • 1
    Oh, and the interface number (if00) will always be 0 for an Arduino. It's the USB interface in the config descriptor. There's 2 interfaces, but one is a master and the other a slave (that's how CDC/ACM works), and interface 0 is the master in the descriptor. The only way to get the interface to change is to reprogram the ATMega16U2 with a different firmware. – Majenko May 28 '18 at 9:25
  • 1
    By the way - the command udevadm info -a /dev/ttyACM0 is useful when crafting udev rules. – Majenko May 28 '18 at 9:35

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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