LabVIEW Interface for Arduino Error 5002: Unable to Establish Connection

Updated Jan 3, 2023

Reported In

Software

  • LabVIEW
  • Third Party Add-Ons

Other

  • Arduino
  • LabVIEW Interface for Arduino (LIFA)

Issue Details

I have a VI that uses the LabVIEW Interface for Arduino toolkit and generates the following error when I run my application.

Error 5002 occurred at Init.vi. Unable to establish connection with Arduino. Please ensure that you have selected the correct COM port and that you have flashed the Arduino with the correct firmware.

Solution

This error occurs when LabVIEW cannot establish a connection with the Arduino microcontroller. Several factors can cause this error so please check the following:
  1. Make sure that the correct firmware is flashed to the Arduino. The correct firmware can be found in <LabVIEW>\vi.lib\LabVIEW Interface for Arduino\Firmware\LIFA_Base. See How Do I Load the LabVIEW Interface for Arduino Firmware Onto My Arduino Uno for steps on flashing the firmware.
  2. Make sure you have selected the correct COM port for the Init.vi or that the VI automatically locates the Arduino (this happens when no wire is connected to the VISA Resource input of the Init.vi and only works for Arduinos that are connected to the PC via USB). If you are having trouble with auto-detect mode, take the Init.vi out of auto-detection mode by wiring up the Arduino VISA resource and baud rate. Right-click on the top left terminal of the Init.vi in and select Create » Constant. This will create a VISA constant. Select the COM port your Arduino is connected to from the drop down menu. The correct COM port to use will be shown in the Arduino Integrated Development Environment (IDE) when you flash the LabVIEW Interface for Arduino (LIFA) firmware to the Arduino board. Right-click the terminal underneath the VISA resource and select Create » Constant again. In this box set the baud rate for your Arduino. The default for most cases will be 115200.
                                                                           
  1. Check to see if your Arduino shows up under Windows Device Manager. Search Device Manager on your computer and run the executable. Expand the USB section and see if your Arduino is listed. If it is not, you may need to install the drivers for your Arduino. See the External Link: Install the Arduino Software (IDE) on Windows PCs for steps on doing this.
 
  1. If using a wireless connection (Xbee, BlueSMIRF) to LabVIEW try using a wired connection (USB, Serial). Poor wireless signal strength can cause the Arduino to be unreachable by LabVIEW.
  2. The USB ports in the back of a desktop computer generally have more stable power supply. You may want to use those ports if on a desktop computer.
  3. Make sure that the baud rate specified as an input to Init.vi matches the baud rate specified in the firmware by #define DEFAULTBAUDRATE X (where X is the baud rate).
  4. Make sure you have the latest version of NI VISA installed on your computer. You can check this by opening NI Measurement & Automation Explorer (NI MAX). Search NI MAX on your computer and run the executable. Expand the software section and verify that NI VISA is listed there. If it is not listed, download the latest version of NI-VISA from NI Driver Downloads .
    
  1. Every program that uses the LIFA Toolkit, should begin with the init command end with the close commands. Ensure that you avoid use of the abort button as much as possible. When you abort a task, your code will not have a chance to run the close VI, and the next time you run your code, the Arduino will start up in an unknown state. You may need to restart the board and re-load the LIFA firmware to correct this.
  2. Make sure that no other programs are open that are also attempting to communicate with the Arduino. If you have the Arduino IDE open, for example, the resource may already be reserved when LabVIEW tries to access the COM port.

Additional Information

Note: The package LabVIEW Interface for Arduino (LIFA) has been replaced with LINX. It is highly recommended to migrate to LINX as there will be no further development for LIFA. See How To Download Digilent LINX For LabVIEW? for more information.

LabVIEW Interface for Arduino (LIFA) is a third-party Add-On for LabVIEW. National Instruments gives support for it through the ni.com/arduino Discussion Forum. This forum is constantly monitored by Arduino/LabVIEW users. You can also find documents, examples, and share knowledge there.