|| 2.46 out of 5
Why Do I Get Error 5002 When Using the LabVIEW Interface for Arduino?
Primary Software Version:
Primary Software Fixed Version:
I have a VI that uses the LabVIEW Interface for Arduino toolkit that 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.
Why do I get this error and what can I do to resolve the problem?
This error occurs when LabVIEW cannot establish a connection with the Arduino microcontroller. Several factors can cause this error so please check the following:
Related Links: Knowledge Base 5LPAQIYG: How Do I Load the LabVIEW Interface for Arduino Firmware Onto My Arduino Uno
- 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 Knowledge Base 5LPAQIYG: How Do I Load the LabVIEW Interface for Arduino Firmware Onto My Arduino Uno for steps on flashing the firmware.
- 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 on 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.
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: Getting started w/ Arduino on Windows
for steps on doing this.
- 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.
- 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.
- 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).
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
- 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.
- 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.