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

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.
  4. ~> cd aws-iot-device-sdk-cpp-<x.y.z>
  1. Create a folder called build to hold the build files. Change to this folder. In-source builds are not allowed.
  2. ~> mkdir build
    ~> cd build
  3. Run cmake in the upper directory.
  4. ~> cmake ../.

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

  5. Build robot arm sample.
  6. ~> make robot-arm-sample
  7. Build switch sample.
  8. ~> make switch-sample
  9. The binaries are located in the build/bin directory.

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

 

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.
  4. ~> 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:

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.