Arduino with Labview: Getting Arduino data through serial communication in labview



Hi Everyone, I hope you are good and doing well in your life. Today I am going to start a series of tutorials on Arduino interfacing with Labview. I have already posted a project on labview with arduino for getting different sensors data on labview. This project is called remote monitoring system using Labview and Zigbee. You can check more details about this project by clicking on this link: Remote monitoring system using Arduino and Xbee.  In this getting started tutorial on Labview with Arduino, you will learn how to interface Arduino with lab view or you can say how to get Arduino data through serial communication on Labview graphical user interface. you should have basic knowledge have basic knowledge of Labview software before starting this project. So let’s start with this tutorial. Arduino with labview



There are many people online looking for how to get Arduino get serially on labview. So I decided to write this article. Labview also provided a tool for Arduino which we can use to program arduino directly from Labview. You just to need to install arduino interfacing with Labview tool in Labview software. I will also write article on it but in this tutorial, we see how to get Arduino date on Labview without using Labview tool for arduino. It can be used in many industrial application. For example it can be used in data acquisition system, real time monitoring system, home automation system etc.

First of all you should have installed any version of Labview installed on your PC, if you do not have, you can download and install this software from after downloading from this link : Download Labview This software is not free of cost. But you can still use demo version for 45 days or you can get it from other sources.  To get data serially on Labview, we need one more driver . This driver is used for serial communication with arduino and Labview VI.  you will not able to get data on Labview without installing driver. Labview also provides other drives for example labview server drivers, labview web services which is used to send labview data to web servers. Follow the following steps:

  • First we all you need to download NI VISA driver.
  • After downloading install this driver.
  • After you done with the installation, NISA driver will automatically create a tool in with the name of COM port as shown in VI below.
  • After installation when you run the Labview first time, this tool will automatically start appearing in labview components window.
  • After install simply run the labview and following window will appear

Labview running



  • Now we need to design VI in Labview. To make VI click on create project after that following window will appear.

Labview create project

  • Now select blank VI and click on Finish. When you click on finish, a blank VI will open, which we used to create our project.
  • Labview has two types of consoles. One is called block diagram where we place all components and other is called front window. Front window is used as graphical user interface and it is where user get its data and make changes in data.  Block diagram and front panel is shown below:
  • labview block diagram and front panelNow you need to design a VI. In this VI we will use VISA resource to get data serially. I have designed a VI which is shown below. In this VI we are getting data from serial port. Arduino will be connected to computer serial port and date received from Arduino will be displayed in response window.
  • VI which I made in labview is shown below.

Labview VI for getting data serailly from Arduino

  • In this VI we are using Loop to get data continuously from Arduino. Response component is used to display data. Block diagram of VI is shown  below.

block diagram of Labview VI

  • You need to select COM port to which Arduino is connected. In my case it is connected with COM4 port. So I selected COM4 port.
  • After that click on start reading and you will getting date in response window.
  • To stop simulation just click on stop simulation and you will stop getting data on  response window.

Arduino with lab view to get data serially

So I have explained all the things above you need to get data on labview from serial port. Now you just need to send data from data to labview through serial port. Connect your Arduino board with your computer and check the COM port to which Arduino is connected. You can check it through device manager of your computer. you can send any data you want. For example, you have connected four sensors with Arduino and you want to measure values of these sensors and want to send sensor values to Labview. For example you have connected temperature, humidity, light and hear beat sensor with Arduino. Arduino will measure these sensors values and send data to labview using serial communication. I have used this example code to send values of temperature , humidity and light sensor to arduino. from Arduino to labview. you can use this code for checking purpose.simulation results

Arduino code to send date to labview

#include<dht.h> // you should include DHT11 library
#include<LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
#define dht_dpin 12 
dht DHT;
unsigned int AnalogValue;
unsigned int light;
byte degree[8] = 
 {
 0b00011,
 0b00011,
 0b00000,
 0b00000,
 0b00000,
 0b00000,
 0b00000,
 0b00000
 };
void setup()
{
 lcd.begin(20, 4);
 Serial.begin(9600);
 lcd.createChar(1, degree);
 lcd.clear();
 lcd.print(" RMS system ");
 delay(2000);
}
void loop()
{
 DHT.read11(dht_dpin);
 lcd.setCursor(0,0);
 lcd.print("Humidity:");
 lcd.print(DHT.humidity); // printing Humidity on LCD
 lcd.print(" %");
 lcd.setCursor(0,1);
 lcd.print("Temperature:");
 lcd.print(DHT.temperature); // Printing temperature on LCD
 lcd.write(1);
 lcd.print("C");
 AnalogValue = analogRead(A0)/ 10.24;
 light = 100 - AnalogValue; 
 lcd.setCursor(0,2);
 lcd.print("light=");
 lcd.print (light);
 lcd.print("%");
 delay(1000);
 Serial.print("Humidity = ");
 Serial.println(DHT.humidity);;
 Serial.print("temperature = ");
 Serial.println(DHT.temperature);
 Serial.print("light intensity = ");
 Serial.println(light);
 
}

So this is all about how to send data serially from Arduino to Lab View.  If you face any issue let me know with your comments.



Add Comment

Subscribe to our blog to get updates in your email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,395 other subscribers