Introduction: Arduino& Labview With 2 DS18B20
Hi! This instructable is for those who want to make an interface with PC and arduino. I chose the popular DS18B20, because there is no clear information about how to do it, more questions than solutions and some VI´s without explanation. I will assume that you are familiar with labview enviroment at basic level.If not, there is a lot of info about this software and how to begin (even a free trial, i think).
http://www.ni.com/labview/why/
Labview also has a tool for arduino :LINX, but do not has support for this sensors.
We will use 2 DS18B20 ,that will give you an idea of how to connect more sensors or send data from your Arduino. This is not the "ultimate" code,so you can modify according to your needs.
You need to watch the video to know how to make the Labview interface. Also, I included the VI ready and the Arduino code.
Step 1: MATERIALS
Software
LabVIEW with VISA (2013)
Arduino IDE (1.6.9)
Hardware
Arduino UNO
2 DS18B20
4.7 K resistor
Breadboard, wires
Step 2: Arduino Side
This is the easiest part. We will read the temperature and send a "string" with a header that will be "filtered" on the labview side.
I am using the inox version of DS18B20 and normal power mode with 4.7 K resistor. Data connected to pin 2.
Red =+5V
Black =Gnd
Blue= Data
-Make sure you have the libraries needed (below).
#include
#include
-Arduino pin for data (2)
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
-Setting serial communication at 9600 (baud rate)
void setup(void) {
Serial.begin(9600);
// Start up the library
sensors.begin();
}
void loop(void) {
-Reading temperatures
sensors.requestTemperatures(); // Send the command to get temperatures
Getting and converting the values to DEC.
If you want °F : sensors.getTempFByIndex()
String sensor1 = String(sensors.getTempCByIndex(0),DEC);
String sensor2 = String(sensors.getTempCByIndex(1),DEC);
We make strings with the headers"A" and "B"
String temp1 = String("A" + sensor1);
String temp2 = String("B" + sensor2);
Print over serial port
Serial.println(temp1);
Serial.println(temp2);
}
Upload the code to Arduino board. Once you have the code running, grab one sensor to raise the temp and identify sensor "A" and "B".
Step 3: Labview Side
For this step you need to watch the video. I tried to make a step by step guide to be clear and show the operation by stages. Anyway, i will upload the VI ready.
The COM port it is the same that on your Arduino IDE.
As you can see, We send two data strings concatenated with an"A" and "B". When enter to the while loop ,there is a delay to control the sample readings. After the read function. the strings goes to the Match pattern, to "filter" each data string. Then, converted to numbers (double) and connected to the thermometers.
You can add more functions like graphics, waves ,etc.
Attachments

Participated in the
Circuits Contest 2016
19 Comments
6 months ago on Step 3
can i use the same diagram block for raspberry . ?
1 year ago
thanks for the cool stuff.
5 years ago
Hi NicolasJ7
is it possible to connect 3 tc's?
Reply 5 years ago
Hi, I've connected 8 sensors with this method
Reply 5 years ago
Thanks again
Reply 5 years ago
OK, you can test the VI just sending strings, send 3 strings concatenated with an A, B and C, and add another structure to capture and show the C, actually ,you don't need a sensor to test it. Watch the video to learn how. Regards
Reply 5 years ago
I did try strings but didn't work think it's because max6675 are not onewire compatible. This my sketch
ardu#include "max6675.h"
int ktcSO = 8;
int ktcCS = 9;
int ktcCS2 = 11;
int ktcCS3 = 12;
int ktcCLK = 10;
MAX6675 ktc(ktcCLK, ktcCS, ktcSO);
MAX6675 ktc2(ktcCLK, ktcCS2, ktcSO);
MAX6675 ktc3(ktcCLK, ktcCS3, ktcSO);
void setup() {
Serial.begin(9600);
// give the MAX a little time to settle
delay(500);
}
void loop() {
// basic readout test
Serial.print("First = ");
Serial.println(ktc.readCelsius());
Serial.print("Second = ");
Serial.println(ktc2.readCelsius());
Serial.print("Third = ");
Serial.println(ktc3.readCelsius());
delay(500);
}
Reply 5 years ago
You dont get it my friend, you can send any value, its not just for onewire devices.
Your value is ktc.readCelsius() (1,2,3)
So:
String sensor1 = String (ktc.readCelsius(),DEC);
Then:
String temp1 =String("A"+sensor1);
Print over serial port:
Serial.println(temp1);
the same for the other sensors...
Just write a number instead "ktc.readCelsius()"to test it, like this:
String sensor1=String( 15.56,DEC);
Thats the way i tested this VI when was created, even before connect any sensor.
Reply 5 years ago
Thanks Nicolas for your help I got it work, brilliant!
5 years ago
Hi . I tried with this code but unfortunately it doesn't work with me . It still 0 in the labview i don't know what the problem
Reply 5 years ago
Thanks so much Nicolas it worked, been trying to achieve this for weeks! You are star!
Reply 5 years ago
Nice!
Reply 5 years ago
This is not my project, maybe you are on the wrong tutorial
6 years ago
Hero, this is exactly what i needed.
Reply 6 years ago
Thanks for the comment!
Reply 5 years ago
" call of overloaded 'string(float&)' is ambiguous "
6 years ago
Nicolas, thank you very much! Great project, all works perfectly!
Reply 6 years ago
Thanks!, I'm glad to help you!
6 years ago
Great project! Thanks for sharing!