Ni Intern Demo Labview Aws
Ni Intern Demo Labview Aws
Ni Intern Demo Labview Aws
Connecting LabVIEW to
Industrial IoT platforms
Connect myRIO to Amazon Web Services (AWS)
Version 1.0, January 2018
Email: [email protected]
Connect myRIO to cloud platforms 2018
Table of Contents
REQUIRED HARDWARE ................................................................................................................................ 2
MYRIO DEMONSTRATION KIT ........................................................................................................................................ 2
Demonstration Kit Components Used ............................................................................................................... 3
REQUIRED HARDWARE COMPONENTS .......................................................................................................................... 4
REQUIRED SOFTWARE.................................................................................................................................. 4
DESCRIPTION ................................................................................................................................................... 5
GOAL OF DEMONSTRATION ............................................................................................................................................. 5
KEY CONCEPTS DEMONSTRATED ................................................................................................................................... 5
DEMO PART 1 - SETTING UP THE AWS SQS ENVIRONMENT............................................................ 6
CREATE AN AWS ACCOUNT ............................................................................................................................................ 6
SETUP SECURITY AND ACCESS CREDENTIALS ............................................................................................................... 6
CREATE QUEUE IN AWS SQS.......................................................................................................................................... 9
DEMO PART 1 - SETTING UP LABVIEW AND MYRIO FOR AWS SQS............................................. 10
DEMO PART 2 – CONNECT LABVIEW TO AWS IOT SERVICES ........................................................ 13
SETTING UP THE AWS ENVIRONMENT....................................................................................................................... 13
SIGN UP WITH AWS IOT ............................................................................................................................................... 14
Create an IoT Thing ............................................................................................................................................... 14
Now we need to create an Certificate and IoT policy. ............................................................................... 15
SETUP A RULE AND ACTION ......................................................................................................................................... 18
DEMO PART 2 – SETTING UP LABVIEW AND MYRIO FOR AWS IOT ............................................ 21
SETUP THE DASHBOARD PAGE ON S3 ................................................................................................... 23
CREATE A BUCKET IN AWS S3 .................................................................................................................................... 23
MODIFY THE HTML PAGES ............................................................................................................................................ 25
UPLOAD INDEX.HTML AND REFRESH.JS TO S3 ....................................................................................................... 26
TROUBLESHOOTING STEPS......................................................................................................................... 0
NETWORK ISSUES: ............................................................................................................................................................ 0
1
Connect myRIO to cloud platforms 2018
REQUIRED HARDWARE
2
Connect myRIO to cloud platforms 2018
3
Connect myRIO to cloud platforms 2018
LED
o Positive pin to A/DIO 7
o Negative pin to GND
Button
o Wire the pin to A/DIO 0 and the other to GND in myRIO
REQUIRED SOFTWARE
LabVIEW 2017 or Newer
LabVIEW FPGA
LabVIEW Real-Time
NI-RIO
myRIO toolkit
LabVIEW Cloud Toolkit for AWS
o http://www.ni.com/gate/gb/GB_EVALTLKTNILVAWS/US
Ensure all software on myRIO is installed, included the Secure HTTP for Clients (SSL) package
4
Connect myRIO to cloud platforms 2018
DESCRIPTION
The session has one demo that consists of two parts:
Please note that the demo requires additional setup at the cloud providers and this may take more time than
expected (for first time users allow 4 hours for full setup). In the demo, we will take measurements (in our case
measure digital I/O state) and store these measurements in the cloud as message in queue.
In the second part of the demo you will use a myRIO to get location from GPS module and input this to the AWS
cloud. This is especially important if there are many edge nodes. The entry point for the cloud with Amazon Web
Services is the AWS IoT service. From here it will be forwarded using the rule engine to a database (DynamoDB).
We will have a html page on the S3 service that pulls the data from the database to highlight the connectivity
between the services.
GOAL OF DEMONSTRATION
The idea of the demonstration is to provide practical information to customer how they can connect embedded
systems to leading cloud platforms. During the first part of the demonstration you will highlight the cloud storage
solution directly from the myRIO system. We will be using the LabVIEW cloud toolkit for AWS to connect to AWS
SQS.
The goal of the second part of the demonstration is to show that LabVIEW and NI myRIO is capable to securely
inject HTTP messages to AWS IoT. We are using LabVIEW Cloud Toolkit for AWS to setup the SSL link.
5
Connect myRIO to cloud platforms 2018
For more information, see AWS Free Usage Tier. The AWS Free Tier account include access to services like AWS
IoT, S3, EC2 and DynamoDB for 12 months. From your AWS account, you can view your AWS account activity,
view usage reports, and manage your AWS Security Credentials.
6
Connect myRIO to cloud platforms 2018
2. IAM is where you create and manage users. Amazon recommends to delete your root account access
key and create limited IAM user keys. As we are simply using the account for demo purposes we will
keep using the root account. Right click the down arrow besides “Delete your root access keys” and
click ‘Manage Security Credentials’
3. Click on ‘Continue to Security Credentials’, then click on ‘Access Keys (Access Key ID and Secret Access
Key)’, to open up the category.
4. Click on the blue button Create New Access Key’
7
Connect myRIO to cloud platforms 2018
5. You will see a popup where you can download the key file.
6. Download the key file and store it in a safe place. The key file is a rootkey.csv file that you can open
with notepad. It’s content looks like:
AWSAccessKeyId=ABCDTHISISNOTREALKEY1OCG5U
AWSSecretKey=ThIs1sN0tAReaLKey123456789+BlaBla
7. You now have two keys: a secret key and an access key. The secret key cannot be recovered. If you lose
the key, you will need to inactivate the access key and create a new key set using the same procedure.
8
Connect myRIO to cloud platforms 2018
Within the service you can work with the service using a web browser (GUI), a command line interface (you need
to download it from AWS, called AWS CLI) or the LabVIEW API.
Amazon Simple Queue Service (Amazon SQS) offers a reliable, highly-scalable hosted queue for storing messages
as they travel between applications or microservices. It moves data between distributed application components
and helps you decouple these components. Amazon SQS provides familiar middleware constructs such as dead-
letter queues and poison-pill management. Amazon SQS supports both standard and FIFO queues. But LabVIEW
Cloud toolkit for AWS only supports standard queue.
1. You will need a queue on AWS SQS to store your messages ; click Create New Queue
2. Enter the queue name (LEDweb) and region. Chose standard queue
NOTE: The name and region you select should match your settings in the LabVIEW application later!
3. Click Quick Create Queue .
4. Repeat step 1 through 3 with queue name LEDmyRIO
9
Connect myRIO to cloud platforms 2018
2. Create a copy of the IoT AWS demo files and open the project in LabVIEW.
3. In the project instance, right-click on the myRIO, select properties and configure the IP address to
match that of your specific myRIO.
4. Connect to the target by right clicking the myRIO item in the project and selecting connect.
5. Open the RT.vi in the project.
6. Set the Access and Secret Key you received earlier on through the AWS IAM service and save the
VI.
10
Connect myRIO to cloud platforms 2018
7. Set the queue name and region matching your settings at Create Queue section.
11
Connect myRIO to cloud platforms 2018
12
Connect myRIO to cloud platforms 2018
13
Connect myRIO to cloud platforms 2018
CREATE AN IO T THING
1. Sign in to the AWS IoT console (http://console.aws.amazon.com/ ).
2. Click Create a Resource. If this is the first time you have accessed the AWS IoT Console, you may need
to click Get Started.
14
Connect myRIO to cloud platforms 2018
2. Click Create a certificate for the device. The certificates will be created and you will need to download
them from the resulting screen.
3. Download all 4 certificates and then click Activate
15
Connect myRIO to cloud platforms 2018
16
Connect myRIO to cloud platforms 2018
7. Now you need to associate the policy with the certificate and the certificate with the thing. Click the
back arrow in the screen, and go to the security menu item>Certificates.
8. Click on the check box of the certificate you just created and click the Actions button and select Attach
a Policy
17
Connect myRIO to cloud platforms 2018
9. In the Policy name dialog box, begin typing the name of your policy. The Name should be auto-
populated. Select the name and click Attach.
10. Repeat the process, selecting Attach a thing
1. Click the Rules section, then Create (or if there’s no rule yet, click ‘Create a Rule’) on the AWS IoT service
Configure the rule:
Name FwdToDatabase
Description leave blank
Attribute VALUE state.reported
Topic Filter (*) $aws/things/myRIO/shadow/update/accepted
Condition leave blank
2. This will send all messages with topic $aws/things/myRIO/shadow/update/accepted to our action.
Click Add action
18
Connect myRIO to cloud platforms 2018
3. Select Insert a message into a DynamoDB table. You can see that there are plenty of options of what you
can do with the data coming into the cloud. Scroll down and click ‘Configure the action’
4. Set the hash key type and value, as well as range key, range key type and range key value.
5. When you click ‘Create a new Resource’ on the table name, it will take you to AWS DynamoDB, which is
where you should configure to the new table. Click Create a table
19
Connect myRIO to cloud platforms 2018
20
Connect myRIO to cloud platforms 2018
NOTE (*) – If you changed the topic in the rule setup you will need to match it to your setup.
7. If you can’t see the data coming in like this format, then correct any of the settings made earlier
(certificate/topic/address/etc.)
8. Next go to the DynamoDB and click on the table you created. Click on the ‘Items’ tab and check if your
data is being added to the table. It should look like
21
Connect myRIO to cloud platforms 2018
22
Connect myRIO to cloud platforms 2018
Within the service you can work with the service using a web browser (GUI), a command line interface (you need
to download it from AWS, called AWS CLI) or the LabVIEW API.
Folders within S3 are called buckets, and files are called objects. Buckets need to have a UNIQUE name (across
AWS!) and buckets can store infinite number of objects. A good way to enforce a unique name is to use your
initials, followed by project followed by some numbers; i.e. evh-nidays-oslo-2017
Buckets can be created in specific regions, such as EU (Ireland), US East or others. This may be important to your
customers if they do not want to store in another country for security reasons, legislation or company policy.
Having data closer may also increase throughput.
1. You will need a bucket (folder) on AWS to store your data; on the S3 page, click Create Bucket
23
Connect myRIO to cloud platforms 2018
3. Click Next to set properties. Here you can select versioning, logging or add tags. You can leave the
default settings and click Next.
4. Set the permissions. Make sure you have permissions to read and write to the object as well as to the
permissions on the objects (access control list).
5. Public permissions should be set to just Read on the objects, as we want to publish our data to
everyone. Click Next, review your settings and then click Create Bucket.
6. Click on your bucket to see the items in your folder. As you see the bucket is still empty.
24
Connect myRIO to cloud platforms 2018
You have already created a bucket to store the datafile in the first demo. Now we will add a html page to this
bucket to display the data from the queue of the first demo as well as the features we stored in the database.
This involves the following steps:
1. Modify the html pages
1. Upload them to S3
25
Connect myRIO to cloud platforms 2018
4. Since we want everyone to be able to view the html file, we need to give everyone read access.
Click next, next, upload
6. Double click the index.html to open the properties, then click the link in the overview tab.
26
Connect myRIO to cloud platforms 2018
NOTE: do not leave your cool dashboard open for extended periods of time on your browser. There is a limit on
the number of times you can access the DynamoDB for free.
7. Click Turn ON button to light up LED on myRIO. Click it again to turn off the LED.
8. Press the button on myRIO to light up LED on the dashboard. Press it again to turn it of
27
TROUBLESHOOTING STEPS
If you receive
Error 412031 (time skewed) -> the time on the myRIO must match at least + 15 minute the AWS time
-> Go into MAX, and set your time zone and set to the current time in your time zone
NETWORK ISSUES:
You will need to have access to internet as well as to the myRIO. The myRIO should also be able to
connect to the internet. Depending on your venue you’re presenting in you have different options:
BEST: Wired internet connection. Always ask for a wired internet connection.
It is most reliable and suitable for the demo and it is also the easiest to setup.
GOOD: Use a wireless router that can act in client or Wi-Fi gateway mode
(travel router). These do not always work but could be a cheap first backup.
These will not always work however, it depends on the hotel network
configuration.