AWS Certification Exam, Microsoft Certification Exam, Types of interoperability

Working with the AWS IoT device SDK for JavaScript– Working with Cloud Computing to Power IoT Solutions

Now, we will install the AWS IoT Device SDK for JavaScript on our device:

To start off, we will first clone the AWS IoT Device SDK from its GitHub repository onto our local directory. To do this, run the following command:
$ cd ~
git clone https://github.com/aws/aws-iot-device-sdk-js-v2.git

We will then navigate to the aws-iot-device-sdk-js-v2 directory that was just created:
$ cd aws-iot-device-sdk-js-v2

We then use npm to install the SDK:
npm install

And with that, we have the AWS IoT Device SDK for JavaScript installed. Now, we can look at running a sample app from the AWS IoT Device SDK.

Running a sample app

We will now run the sample app, which is able to publish and subscribe to topics within IoT Core:

Set the directory to the aws-iot-device-sdk-js-v2/samples/node/pub_sub directory, which was created by the SDK, and install the given sample app with the following commands:
$ cd ~/aws-iot-device-sdk-js-v2/samples/node/pub_sub
$ npm install

Get your IoT endpoint, which you need to use later, with the following command:
$ aws iot describe-endpoint –endpoint-type iot:Data-ATS

Insert the endpoint that you have received within the following command and run it:
$ node dist/index.js –topic topic_1 –ca_file ~/certs/Amazon-root-CA-1.pem –cert ~/certs/device.pem.crt –key ~/certs/private.pem.key –endpoint your-iot-endpoint

Now, you have an app that connects to the AWS IoT service, subscribes to a message topic called topic_1, outputs the messages that it can receive on the topic, publishes 10 messages to the topic, and displays an output similar to the following:

Publish received on topic topic_1
{“message”:”Hello world!”,”sequence”:1}
Publish received on topic topic_1
{“message”:”Hello world!”,”sequence”:2}
Publish received on topic topic_1
{“message”:”Hello world!”,”sequence”:3}

With this, we can also view the messages from the sample app from AWS IoT.

Viewing messages from the sample app within AWS IoT

We want to observe the messages from the sample app, as they navigate via the message broker using the MQTT client on the AWS IoT platform. To monitor the published MQTT messages, follow these instructions:

Access the MQTT client located within the AWS IoT dashboard.

Let the client connect to the topic_1 topic previously established.

Once you’re in the Amazon EC2 Instance Connect interface, initiate the sample app once more and observe the incoming messages in the MQTT client.

And with that, you’ve just built your first IoT system on AWS! These kinds of systems are very powerful for understanding how the benefits of IoT can permeate throughout the cloud and leverage the resources that are provided well.

Now, we can move ahead and look at how we can optimize for resilience and low latency on our deployments.

Leave a Reply

Your email address will not be published. Required fields are marked *