Getting Started with AWS IoT on Moxa UC-8100-LX Using
Embedded C SDK
Jimmy Chen (陳永達)
Field Application Engineer
jimmy.chen@moxa.com

Contents
1

Background ..................................................................................... 2

2

Requirement ................................................................................... 2

3

Overview......................................................................................... 2
3.1

Preparing the AWS IoT C SDK Environment on the UC-8100-LX ...................... 3

3.2

Building the C SDK Source Code ................................................................. 4

3.3

Connecting to the AWS IoT Console ............................................................ 64

Additional Reading .......................................................................... 6

Copyright © 2017 Moxa Inc.

Released on January 11, 2017

About Moxa
Moxa is a leading manufacturer of industrial networking, computing, and automation
solutions. With over 25 years of industry experience, Moxa has connected more than 30
million devices worldwide and has a distribution and service network that reaches
customers in more than 70 countries. Moxa delivers lasting business value by empowering
industry with reliable networks and sincere service for automation systems. Informationabout Moxa’s solutions is available at www.moxa.com. You may also contact Moxa by email
at info@moxa.com.
How to Contact Moxa
Tel:Fax:+886-2-8919-1230+886-2-8919-1231

Moxa Tech Note

Getting Started with AWS IoT on Moxa
UC-8100-LX Using Embedded C SDK

The instructions in this tech note apply only to the Moxa UC-81XX series ofcomputers. These instructions MAY NOT be suitable for use in othercomputers because of the different Debian distribution versions, hardware
peripherals, and firmware versions.
The instructions in this document require familiarity with the Amazon AWS
IoT console. Additional details on the Amazon AWS IoT console areavailable at: https://aws.amazon.com/documentation/iot/

1 Background
The purpose of this document is to provide step-by-step instructions on how to run the Amazon
AWS IoT embedded C software development kit (SDK) on the UC-8100-LX computer.

2 Requirement•UC-8100-LX/ UC-8100-LX-ME•

Amazon AWS IoT account3 Overview
The UC 8100-LX computer comes preinstalled with the Debian Linux distribution. You should firstinstall all dependent libraries and tools for this distribution, especially the ones for C SDK, before
building software packages on the computer.
Once you have installed all the libraries and tools required for this distribution on your computer,follow the instruction given in the sections:
1. Preparing the AWS IoT C SDK environment on the UC-8100-LX
2. Building the C SDK source code
3. Connecting to the AWS IoT console

Copyright © 2017 Moxa Inc.

Page 2 of 6

Moxa Tech Note

Getting Started with AWS IoT on Moxa
UC-8100-LX Using Embedded C SDK

3.1 Preparing the AWS IoT C SDK Environment on the UC-8100-LX
3.1.1 Libraries and Tools
You will need a native compiler environment and SSL libraries to compile the C sourcecode on the UC-8100-LX. Run the following commands on the UC-8100-LX with root
authentication to connect to the repository and install the libraries and tools required
to compile C code:
1. #apt-get update

2. #apt-get upgrade

3. #apt-get install build-essential -y
4. #apt-get install git -y

5. #apt-get install cmake -y

3.1.2 Building the C Source CodeAmazon C SDK is available free of cost at:https://github.com/aws/aws-iot-device-sdk-embedded-C
Figure 1

Download the C SDK from the Amazon website and then use the Git tool to download thesource code and dependent libraries to the UC-8100-LX/home/moxa directory on thecomputer using the following commands:

Copyright © 2017 Moxa Inc.

Page 3 of 6

Moxa Tech Note

Getting Started with AWS IoT on Moxa
UC-8100-LX Using Embedded C SDK

1. #cd /home/moxa

2. #git clone https://github.com/aws/aws-iot-device-sdk-embedded-C.git
3. #git clone https://github.com/cpputest/cpputest.git

4. #cp -a cpputest/* aws-iot-device-sdk-embedded-C/external_libs/CppUTest/
5. #git clone https://github.com/ARMmbed/mbedtls.git

6. #cp -a mbedtls/* aws-iot-device-sdk-embedded-C/external_libs/mbedTLS/
7. #cd aws-iot-device-sdk-embedded-C
8. #make

3.2 Building the C SDK Source CodeOnce you have the source code and libraries that you need on your computer, it is time to build
the source code samples. Before you go any further, register a thing account for your resourcewith AWS by login in to the Amazon Management Console and clicking on the AWS IoT link.
This will enable you to download certification files on your computer.
The following screenshots show an example for registering an Amazon thing for a UC-8100-LX
device (Figure 2 and Figure 3) and downloading the corresponding certification files (Figure 4).
Figure 2Copyright © 2017 Moxa Inc.

Page 4 of 6

Moxa Tech Note

Getting Started with AWS IoT on Moxa
UC-8100-LX Using Embedded C SDK

Figure 3

Once you have registered a thing object, AWS assigns it a unique resource name and a certificate.
You should be able to download the certificate files to your desktop computer via a browser. Use
WinSCP or FileZilla (Figure 4) to upload these certificate files to the following Amazon C SDK
source code directory on the UC-8100-LX machine:[PATH_OF_SOURCE_CODE]/aws-iot-device-sdk-embedded-C/certs.
Figure 4

Copyright © 2017 Moxa Inc.

Page 5 of 6

Moxa Tech Note

Getting Started with AWS IoT on Moxa
UC-8100-LX Using Embedded C SDK

You can modify/edit the sample code header file (aws_iot-config.h) to best fit your thing resource
and its policy. Sample header files are available at:https://github.com/aws/aws-iot-device-sdk-embedded-C/tree/master/samples
Run the commands listed below to build your source code:
1. #cd [PATH_OF_SOURCE_CODE]/aws-iot-device-sdk-embedded-C
2. #make

3. #cd [PATH_OF_SOURCE_CODE]/

aws-iot-device-sdk-embedded-C/samples/linux/subscribe_publish_sample

4. #make

You are now ready to run your sample programs.

3.3 Connecting to the AWS IoT ConsoleWe run one of the sample programs using the #./subscribe_publish_sample command to view
the AWS IoT Console as shown in Figure 5 below:Figure 5

You are all set once you see the Successful connection status on your AWS IoT dashboard.

4 Additional Reading•

http://docs.aws.amazon.com/iot/latest/developerguide/iot-device-sdk-c.html•

http://www.moxa.com/product/uc-8100.htm

Copyright © 2017 Moxa Inc.

Page 6 of 6