Skip to content

tutorial usb serial visa

Ken Sharp edited this page Feb 26, 2026 · 1 revision

Using USB Serial Ports on Raspberry Pi with LabVIEW + VISA

This tutorial shows how to connect a USB serial device (for example, Arduino) to a Raspberry Pi and communicate with it from LabVIEW using VISA.

What you will learn

  • How to identify the correct serial device on Raspberry Pi (/dev/tty*)
  • How to map Linux serial devices to VISA resource names
  • How to open, read, and write to the port in LabVIEW
  • How to make port selection reliable across reboots and re-plugs

Prerequisites

  • Raspberry Pi running LINX-supported Linux image
  • LabVIEW with NI-VISA installed
  • USB serial device (Arduino, USB-UART adapter, etc.)
  • USB cable and basic serial test firmware on the device

1) Connect and identify the device on Raspberry Pi

Plug in the USB serial device, then run:

dmesg | tail -n 50
ls -l /dev/ttyACM* /dev/ttyUSB* 2>/dev/null

Typical results:

  • Arduino CDC device: /dev/ttyACM0
  • USB-UART adapter: /dev/ttyUSB0

To get stable identity info (vendor/product/serial):

udevadm info -a -n /dev/ttyACM0 | less

Useful command for quick USB listing:

lsusb

2) Understand VISA resource naming on Linux

On Linux, NI-VISA serial resources commonly map like this:

  • /dev/ttyACM0 -> ASRL/dev/ttyACM0::INSTR
  • /dev/ttyUSB0 -> ASRL/dev/ttyUSB0::INSTR

In LabVIEW, you can also use VISA Find Resource with:

  • ?*INSTR (broad search), then filter to ASRL...
  • ASRL?*INSTR (serial-focused search)

3) Build a LabVIEW VI to scan the available ports

Create a VI with this basic flow:

  1. VISA Find Resource (ASRL?*INSTR)
  2. Loop through returned resources
  3. For each resource:
    • VISA Open
    • VISA Property Node
      • Interface Description
      • Interface Number
      • Interface Type

Recommended serial settings to expose on front panel:

  • VISA Resource Name
  • Interface Name
  • Interface Number
  • Interface Type

Example LabVIEW diagram

Also note that there is a premade VI that can scan and map serial ports available in this forum post.

4) Quickly verify the port from terminal (recommended)

Before debugging LabVIEW, test the device in terminal:

stty -F /dev/ttyACM0 115200 -echo -icanon
echo "ping" > /dev/ttyACM0
cat /dev/ttyACM0

Or use screen:

screen /dev/ttyACM0 115200

If terminal communication fails, fix that first (cable, firmware, baud, permissions).

5) Fix common issues

Permission denied on /dev/ttyACM0 or /dev/ttyUSB0

Add your user to serial-related groups and re-login:

sudo usermod -aG dialout $USER
sudo usermod -aG tty $USER

Port number changes (ACM0 -> ACM1)

Use a persistent udev symlink.

Example rule:

sudo nano /etc/udev/rules.d/99-linx-serial.rules

Add (update IDs for your device):

SUBSYSTEM=="tty", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="0043", SYMLINK+="linx_arduino"

Reload rules and replug device:

sudo udevadm control --reload-rules
sudo udevadm trigger

Then use VISA resource:

  • ASRL/dev/linx_arduino::INSTR

VISA timeout

  • Increase VISA timeout (for example 2000-5000 ms)
  • Confirm termination character behavior
  • Ensure device is actually transmitting line endings expected by your VI

6) Suggested robust selection strategy

For systems with multiple serial devices:

  1. Enumerate ASRL?*INSTR
  2. For each resource, open and send lightweight probe command
  3. Match expected response pattern
  4. Cache selected resource in config file
  5. Re-scan only if open/read fails

This is typically more reliable than hard-coding ttyACM0.

Summary

Using USB serial on Raspberry Pi with LabVIEW is straightforward once you:

  • Identify the Linux device node
  • Map to the VISA resource string
  • Configure matching serial settings
  • Add a robust discovery strategy for multi-device or changing-port systems

For LINX projects, this is a practical way to communicate with Arduino-class devices and USB-UART peripherals when network transport is not required.

Clone this wiki locally