LabVIEW LINX, Arduino and ThingSpeak

35
LabVIEW LINX, Arduino and ThingSpeak Hans-Petter Halvorsen https://www.halvorsen.blog

Transcript of LabVIEW LINX, Arduino and ThingSpeak

Page 1: LabVIEW LINX, Arduino and ThingSpeak

LabVIEW LINX, Arduino and ThingSpeak

Hans-Petter Halvorsen

https://www.halvorsen.blog

Page 2: LabVIEW LINX, Arduino and ThingSpeak

• Arduino• ThingSpeak• LabVIEW• LabVIEW LINX• Example–Write Data to ThingSpeak using a TMP36

Temperature Sensor

Table of Contents

Page 3: LabVIEW LINX, Arduino and ThingSpeak

System Overview

Sensors

Arduino UNOPC

USB cable Type A-B

LabVIEW+

LabVIEW LINX Toolkit

TMP36 Temperature Sensor

ThingSpeakCloud Service

Temperature

Page 4: LabVIEW LINX, Arduino and ThingSpeak

Hardware• Arduino• Breadboard• Wires (Jumper Wires) • TMP36 Temperature Sensor

Page 5: LabVIEW LINX, Arduino and ThingSpeak

Arduino

Hans-Petter Halvorsen

https://www.halvorsen.blog

Table of Contents

Page 6: LabVIEW LINX, Arduino and ThingSpeak

• Arduino is an open-source electronics platform based on easy-to-use hardware and software.

• It's intended for anyone making interactive projects, from kids to grown-ups.

• You can connect different Sensors, like Temperature, etc.

• It is used a lots in Internet of Things projects• Homepage:

https://www.arduino.cc

Arduino

Page 7: LabVIEW LINX, Arduino and ThingSpeak

Arduino• Arduino is a Microcontroller• Arduino is an open-source platform

with Input/Output Pins (Digital In/Out, Analog In and PWM)• Price about $20• Arduino Starter Kit ~$40-80

with Cables, Wires, Resistors, Sensors, etc.

Page 8: LabVIEW LINX, Arduino and ThingSpeak

Connect Arduino to your PC

USB cable Type A-B

PC

Arduino

Page 9: LabVIEW LINX, Arduino and ThingSpeak

Arduino Software

In this window you create your

Program

Compile and Check if Code is OK

Creates a New Code Window

Open existing Code

Upload Code to Arduino Board Save

Open Serial Monitor

Error Messages can be seen herewww.arduino.cc

The software can be downloaded for free:

Page 10: LabVIEW LINX, Arduino and ThingSpeak

Arduino Programs// Initialization, define variables, etc.

void setup(){

// Initialization...

}

void loop(){

//Main Program...

}

All Arduino programs must follow the following main structure:

Page 11: LabVIEW LINX, Arduino and ThingSpeak

ThingSpeak

Hans-Petter Halvorsen

https://www.halvorsen.blog

Table of Contents

Page 12: LabVIEW LINX, Arduino and ThingSpeak

• ThingSpeak is an IoT analytics platform service that lets you collect and store sensor data in the cloud and develop Internet of Things (IoT) applications.

• ThingSpeak has a free Web Service (REST API) that lets you collect and store sensor data in the cloud and develop Internet of Things applications.

• It works with Arduino, Raspberry Pi, MATLAB and LabVIEW, Python, etc.

https://thingspeak.com

ThingSpeak

Page 13: LabVIEW LINX, Arduino and ThingSpeak

ThingSpeak

https://thingspeak.com

Page 14: LabVIEW LINX, Arduino and ThingSpeak

LabVIEW

Hans-Petter Halvorsen

https://www.halvorsen.blog

Table of Contents

Page 15: LabVIEW LINX, Arduino and ThingSpeak

• LabVIEW is Graphical Software• LabVIEW has powerful features for

Simulation, Control and DAQ Applications

LabVIEW

Basic LabVIEW Example:

Page 16: LabVIEW LINX, Arduino and ThingSpeak

LabVIEW HTTP ClientWe can use the built-in LabVIEW HTTP Client Functions in order to communicate with the ThingSpeak REST API

Page 17: LabVIEW LINX, Arduino and ThingSpeak

LabVIEW LINX

Hans-Petter Halvorsen

https://www.halvorsen.blog

Table of Contents

Page 18: LabVIEW LINX, Arduino and ThingSpeak

• The LabVIEW LINX Toolkit adds support for Arduino, Raspberry Pi, and BeagleBone embedded platforms• We will use an Arduino Uno in this

Tutorial

LabVIEW LINX Toolkit

Page 19: LabVIEW LINX, Arduino and ThingSpeak

Installing LabVIEW LINX ToolkitUse VI Package Manager

Note: Do not install this package if you are running LabVIEW 2020 Community Edition or later, as the Community Edition already includes the LabVIEW LINX Toolkit

Page 20: LabVIEW LINX, Arduino and ThingSpeak

LabVIEW LINXNote! In order to use Arduino with LabVIEW LINX you need to update the Firmware on

the Arduino device

Page 21: LabVIEW LINX, Arduino and ThingSpeak

LINX Firmware WizardNote! In order to use Arduino with LabVIEW LINX you need to update the Firmware on

the Arduino device

Page 22: LabVIEW LINX, Arduino and ThingSpeak

LabVIEW LINX Palette

Page 23: LabVIEW LINX, Arduino and ThingSpeak

TMP36 Example

Hans-Petter Halvorsen

https://www.halvorsen.blog

Table of Contents

Page 24: LabVIEW LINX, Arduino and ThingSpeak

System Overview

Sensors

Arduino UNOPC

USB cable Type A-B

LabVIEW+

LabVIEW LINX Toolkit

TMP36 Temperature Sensor

ThingSpeakCloud Service

Temperature

Page 25: LabVIEW LINX, Arduino and ThingSpeak

TMP36

TMP is a small, low-cost temperature sensor and cost about $1 (you can buy it “everywhere”)

Page 26: LabVIEW LINX, Arduino and ThingSpeak

Linear ScalingConvert form Voltage (V) to degrees CelsiusFrom the Datasheet we have:

(𝑥!, 𝑦!) = (0.75𝑉, 25°𝐶)(𝑥", 𝑦") = (1𝑉, 50°𝐶)

There is a linear relationship between Voltage and degrees Celsius:

𝑦 = 𝑎𝑥 + 𝑏

We can find a and b using the following known formula:

𝑦 − 𝑦! =𝑦" − 𝑦!𝑥" − 𝑥!

(𝑥 − 𝑥!)

This gives:

𝑦 − 25 =50 − 251 − 0.75

(𝑥 − 0.75)

Then we get the following formula:𝑦 = 100𝑥 − 50

Page 27: LabVIEW LINX, Arduino and ThingSpeak

Wiring

Page 28: LabVIEW LINX, Arduino and ThingSpeak

LabVIEW

Page 29: LabVIEW LINX, Arduino and ThingSpeak

LabVIEW

Page 30: LabVIEW LINX, Arduino and ThingSpeak

LabVIEW

Page 31: LabVIEW LINX, Arduino and ThingSpeak

LabVIEW

Page 32: LabVIEW LINX, Arduino and ThingSpeak

ThingSpeakWe see that the Temperature Data has been successfully written to ThingSpeak

Page 33: LabVIEW LINX, Arduino and ThingSpeak

Summary• We have successfully logged Temperature Data

to the ThingSpeak Cloud Service using an Arduino UNO device.

• The Programming Environment has been LabVIEW and the LabVIEW LINX Toolkit

• The Temperature Sensor was a TMP36Temperature Sensor

Page 34: LabVIEW LINX, Arduino and ThingSpeak

Final System

Sensors

Arduino UNOPC

USB cable Type A-B

LabVIEW+

LabVIEW LINX Toolkit

TMP36 Temperature Sensor

ThingSpeakCloud Service

Temperature

Page 35: LabVIEW LINX, Arduino and ThingSpeak

Hans-Petter Halvorsen

University of South-Eastern Norwaywww.usn.no

E-mail: [email protected]: https://www.halvorsen.blog