Arduino& Labview With 2 DS18B20

9,699

59

17

Intro: 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.

3 People Made This Project!

Recommendations

  • Audio Contest 2018

    Audio Contest 2018
  • Electronics Tips & Tricks Challenge

    Electronics Tips & Tricks Challenge
  • Plastics Contest

    Plastics Contest

17 Discussions

0
None
NicolasJ7fatmat5

Reply 4 months ago

Hi, I've connected 8 sensors with this method

0
None
fatmat5NicolasJ7

Reply 4 months ago

Thanks for the reply Nicolas. I managed to connect 3 Max6675 breakouts and thermocouples and created a sketch and it worked. The problem came trying to create a VI it wouldn't work. I asked in all the forums with no answers. I will try your method when parts arrive.

Thanks again

0
None
NicolasJ7fatmat5

Reply 4 months 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

0
None
fatmat5NicolasJ7

Reply 4 months 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);

}

0
None
NicolasJ7fatmat5

Reply 4 months 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.

0
None
fatmat5NicolasJ7

Reply 4 months ago

Thanks Nicolas for your help I got it work, brilliant!

0
None
SouhailM

5 months 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

IMG_20180511_011528.jpgIMG_20180511_010949.jpgIMG_20180511_011545.jpgIMG_20180511_010918.jpg
3 replies
0
None
fatmat5SouhailM

Reply 4 months ago

Thanks so much Nicolas it worked, been trying to achieve this for weeks! You are star!

0
None
NicolasJ7SouhailM

Reply 5 months ago

This is not my project, maybe you are on the wrong tutorial

0
None
PieroB7NicolasJ7

Reply 7 months ago

hi, your arduino side file gives me this error:

" call of overloaded 'string(float&)' is ambiguous "

I'm going crazy, why?
sorry my english
Piero
0
None
approxime

1 year ago

Nicolas, thank you very much! Great project, all works perfectly!

1 reply
0
None
cher_djamel

1 year ago

Great project! Thanks for sharing!