Show Contents

# 7. Set up your AWS IoT Things

Once the Greengrass group is defined and the core is deployed and running, you must set up the two things that are also part of the defined group: the switch and robot arm things. These two devices are simulated with code running on your development PC or using two different computers.

Follow these steps to set up your AWS IoT Things:

- 7.1. Build switch and robot arm samples
- 7.2. Install your thing certificates
- 7.3. Configure the samples

## 7.1. Build switch and robot arm samples

The switch and robot arm sample code is included inside the AWS IoT C++ device SDK. You can build and run both samples in the same Linux PC, or you can use two machines (one per device).

Follow these instructions to compile the samples on your Linux development machine:

1. Download the AWS IoT C++ Device SDK version 1.1.0 from GitHub.
2. Decompress the downloaded file.
3. Change to the aws-iot-device-sdk-cpp-<x.y.z> folder.

    ~> cd aws-iot-device-sdk-cpp-<x.y.z>

4. Create a folder called build to hold the build files. Change to this folder. In-source builds are not allowed.

    ~> mkdir build
    ~> cd build

5. Run cmake in the upper directory.

    ~> cmake ../.

The command downloads required third-party libraries and generates a makefile.

6. Build robot arm sample.

    ~> make robot-arm-sample

7. Build switch sample.

    ~> make switch-sample

8. The binaries are located in the build/bin directory.

Note To build these examples you need CMake and OpenSSL 1.0.2.

Install CMake 3.8.0

Note Issue the following commands in your development computer to install CMake 3.8.0:

    wget https://cmake.org/files/v3.8/cmake-3.8.0.tar.gz
    tar -zxf cmake-3.8.0.tar.gz
    cd cmake-3.8.0
    ./configure
    make
    sudo make install

Install OpenSSL 1.0.2

Note Issue the following commands in the development computer to install OpenSSL 1.0.2:

    wget https://www.openssl.org/source/openssl-1.0.2k.tar.gz
    tar -xvzf openssl-1.0.2k.tar.gz
    cd openssl-1.0.2k
    ./config --prefix=/usr/
    make
    sudo make install

## 7.2. Install your thing certificates

The robot arm and the switch devices need certificates to authenticate with AWS IoT and retrieve the connectivity information of your Greengrass core. You downloaded these certificates in step 4.2. Create device things.

1. Download the AWS IoT root CA certificate from Symantec/Verisign.
2. Place the RobotArm_Thing certificates into aws-iot-device-sdk-cpp-<x.y.z>/build/bin/certs/robotArm:
   1. Copy the AWS IoT root CA certificate.

       ~> cp root-ca.pem <parent_absolute_path>/aws-iot-device-sdk-cpp-<x.y.z>/build/bin/certs/robotArm/

   1. Copy the certificate and private key associated with the robot arm.

       ~> cp <id>.pem.crt <parent_absolute_path>/aws-iot-device-sdk-cpp-<x.y.z>/build/bin/certs/robotArm/
       ~> cp <id>-private.pem.key <parent_absolute_path>/aws-iot-device-sdk-cpp-<x.y.z>/build/bin/certs/robotArm/

3. Place the Switch_Thing certificates into aws-iot-device-sdk-cpp-<x.y.z>/build/bin/certs/switch:
   1. Copy the AWS IoT root CA certificate.

       ~> cp root-ca.pem <parent_absolute_path>/aws-iot-device-sdk-cpp-<x.y.z>/build/bin/certs/switch/

   1. Copy the certificate and private key associated with the switch.

    ~> cp <id>.pem.crt <parent_absolute_path>/aws-iot-device-sdk-cpp-<x.y.z>/build/bin/certs/switch/
    ~> cp <id>-private.pem.key <parent_absolute_path>/aws-iot-device-sdk-cpp-<x.y.z>/build/bin/certs/switch/

## 7.3. Configure the samples

Inside the aws-iot-device-sdk-cpp-<x.y.z>/build/bin/config/ directory you can find the configuration files for your things:

- RobotArmConfig.json
- SwitchConfig.json

Edit these files and change:

Parameter | Description | Robot Arm value | Switch value
--- | --- | --- | ---
endpoint | The IP address or domain of the AWS IoT endpoint. | greengrass.iot.us-west-2.amazonaws.com | greengrass.iot.us-west-2.amazonaws.com
root_ca_relative_path | The AWS IoT root CA certificate from Symantec/Verisign. | certs/robotArm/root-ca.pem | certs/switch/root-ca.pem
device_certificate_relative_path | The device certificate for each thing. | certs/robotArm/<id>.pem.crt | certs/switch/<id>.pem.crt
device_private_key_relative_path | The private key for each thing. | certs/robotArm/<id>.private.pem.key | certs/switch/<id>.private.pem.key

Note Replace us-west-2 with the region you are using to access Greengrass.

© 2018 Digi International Inc. All rights reserved.
7. Set up your AWS IoT Things updated on 22 January 2018 02:43:38 PM