Click here to Skip to main content
14,140,660 members
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

5.2K views
Posted 13 Nov 2015
Licenced CPOL

Setting up AWS IoT Device SDK on the Intel® Edison Board

, 13 Nov 2015
Rate this:
Please Sign up or sign in to vote.
This tutorial will walk you through the process of installing the AWS IoT SDK and show you how to make basic MQTT calls.

This article is for our sponsors at CodeProject. These articles are intended to provide you with information on products and services that we consider useful and of value to developers

Get access to the new Intel® IoT Developer Kit, a complete hardware and software solution that allows developers to create exciting new solutions with the Intel® Galileo and Intel® Edison boards. Visit the Intel® Developer Zone for IoT.

This tutorial will walk you through the process of installing the AWS IoT SDK and show you how to make basic MQTT calls. Before you begin connecting your Intel® Edison board, you will need to ensure the latest OS image has been installed. To do that, follow the getting started instructions based on your host machine: Windows, Mac, or Linux. After following the standard Intel® Edison setup instructions, you will need to establish a serial connection to your device from your machine. Once you have established a serial connection (command line) to your Intel® Edison board, you can proceed to install the AWS IoT SDK using the below instructions.

Before you begin…

  • Make sure you have run the configure_edison --setup command to set up your board
  • Make sure your Intel® Edison board is online via your local Wi-Fi network (should occur during configure_edison setup)

Install AWS CLI

The AWS CLI is a way to manage your AWS services from your board. You need this first in order to download the SDK.

First, you need to install pip (Python package manager):

curl https://bootstrap.pypa.io/ez_setup.py -o - | python
easy_install pip

Next, install the AWS CLI with pip:

pip install awscli

Note: In order to view the help files ("aws iot help") you need to install Groff and a non-BusyBox version of less.

For Groff:

wget http://ftp.gnu.org/gnu/groff/groff-1.22.3.tar.gz
tar -zxvf groff-1.22.3.tar.gz
cd groff-1.22.3

./configure

make
make install
export PATH=$PATH:/usr/local/bin/
cd ~

For Less:

First rename the old version of less

mv /usr/bin/less /usr/bin/less-OLD

Then install the new version of less

wget http://www.greenwoodsoftware.com/less/less-458.zip
upzip less-458.zip
cd less-458.zip
chmod 777 /*
./configure
make
make install
cd ~

To make sure everything has installed correctly, run the iot help file:

aws iot help

Get AWS credentials:

At this point, you should have AWS CLI installed. Make new user and get credentials from the AWS console following instructions at: http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-set-up.html#cli-signup. Once you have an Access ID and Key you can configure AWS and enter the ID and Key with:

aws configure

NOTE: for default region you must enter us-east-1 in order to be able to configure the AWS IoT. The default format can be left as json.

In order to get permission to download the AWS IoT tools you need to associate the administrator account policy to the user that you created. To do this go to the users panel in the IAM console, select the user you created, attach policy, and select administrator account.

Generate Certificates:

First create a folder to store your certificates in:

mkdir aws_certs

cd aws_certs

Generate a private key with open ssl:

openssl genrsa -out privateKey.pem 2048
openssl req -new -key privateKey.pem -out cert.csr

Fill out the fields with your info.

Run the following to activate the certificate:

aws iot --endpoint-url https://i.us-east-1.pb.iot.amazonaws.com create-certificate --certificate-signing-request file://cert.csr --set-as-active > certOutput.txt

Run the following to save the certificate into a cert.pem file:

aws iot --endpoint-url https://i.us-east-1.pb.iot.amazonaws.com describe-certificate --certificate-id <certificate ID> --output text --query certificateDescription.certificatePem > cert.pem

NOTE: Replace <certificate ID> with the ID stored in the "certificateId" field in certOutput.txt. To view the file enter: more certOutput.txt

Create a Json policy document for AWS IoT SDK:

Copy the following text (ctrl-c):

{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action":["iot:*"],
"Resource": ["*"]
}]
}

Enter vi policy.doc hit a and right click to paste the text

Hit escape and type in :wq to save and quit

First enter:

aws iot --endpoint-url https://i.us-east-1.pb.iot.amazonaws.com create-policy --policy-name PubSubToAnyTopic --policy-document file://policy.doc

Then attach the policy to the certificate with:

aws iot --endpoint-url https://i.us-east-1.pb.iot.amazonaws.com attach-principal-policy --principal-arn <principal arn> --policy-name "PubSubToAnyTopic"

NOTE: replace <principal arn> with the value stored in "certifcateArn" in the outputCert.txt file.

Use MQTT to subscribe and publish to AWS

Now that the certificates are in order we can use MQTT to subscribe and publish to the cloud.

First get the root CA pem file:

curl https://www.symantec.com/cerisign/roots/VeriSign-Class%203-Public-Primary-Certification-Authority-G5.pem > rootCA.pem

Use the moquitto client to subscribe to a topic:

mosquitto_sub --cafile rootCA.pem --cert certs\cert.pem --
key privateKey.pem -h g.us-east-1.pb.iot.amazonaws.com -p 8883
-q 1 -d -t <topic> -i <client_id>

NOTE: replace <topic> and <client_id> with the topic you wish to subscribe to and the id you wish to have.

Use mosquitto to publish to a topic:

mosquitto_pub --cafile crootCA.pem --cert certs\cert.pem --
key privateKey.pem -h g.us-east-1.pb.iot.amazonaws.com -p 8883
-q 1 -d -t <topic> -i <client_id> -m <"message">

NOTE: Replace <topic>, <client_id>, and <"message"> with the topic, client id and message you wish to publish. the message must be in quotes.

For tutorials showing how to use various features within the AWS IoT SDK on your Intel Edison Board, see https://github.com/intel-iot-devkit/aws-iot-intel

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Intel Corporation
United States United States
You may know us for our processors. But we do so much more. Intel invents at the boundaries of technology to make amazing experiences possible for business and society, and for every person on Earth.

Harnessing the capability of the cloud, the ubiquity of the Internet of Things, the latest advances in memory and programmable solutions, and the promise of always-on 5G connectivity, Intel is disrupting industries and solving global challenges. Leading on policy, diversity, inclusion, education and sustainability, we create value for our stockholders, customers and society.
Group type: Organisation

43 members


You may also be interested in...

Comments and Discussions

 
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web06 | 2.8.190518.1 | Last Updated 13 Nov 2015
Article Copyright 2015 by Intel Corporation
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid