Developer Guide

Using the AWS IoT Embedded C SDK

Set Up the Runtime Environment for the AWS IoT Embedded C SDK

  1. Download the AWS IoT Device SDK for C from the following GitHub repository:

    git clone -b release

  2. Before you can use the AWS IoT Embedded C SDK, you must download all required third-party libraries from GitHub. You can find instructions for doing this in the deviceSDK/external_libs folder.

Sample App Configuration

The AWS IoT Embedded C SDK includes sample apps for you to try. For simplicity, we are going to run subscribe_publish_sample.

  1. Copy your certificate, private key, and root CA certificate into the deviceSDK/certs directory.

    To get the root CA certificate, review the documentation on Server Authentication in AWS IoT Core and follow the links to the appropriate CA certificate. Copy the root CA text from the browser, paste it into a file, and then copy it into the deviceSDK/certs directory.


    Device and root CA certificates are subject to expiration or revocation. If this should occur, you must copy a new CA certificate or private key and device certificate onto your device.

  2. Navigate to the deviceSDK/sample_apps/subscribe_publish_sample directory. You must configure your personal endpoint, private key, and certificate. The personal endpoint is the REST API endpoint you noted earlier. If you don't remember the endpoint and you have access to a machine with the AWS CLI installed, you can use the aws iot describe-endpoint command to find your personal endpoint URL. Or, go to the AWS IoT console. Choose Registry, choose Things, and then choose the thing that represents your Raspberry Pi. On the Details page for the thing, in the left navigation pane, choose Interact. Copy everything, including ".com", from REST API endpoint.

  3. Open the aws_iot_config.h file and, in the //Get from console section, update the values for the following:


    Your personal endpoint.


    Your thing name.


    Your root CA certificate.


    Your certificate.


    Your private key.

    For example:

    // Get from console // ================================================= #define AWS_IOT_MQTT_HOST "" #define AWS_IOT_MQTT_PORT 8883 #define AWS_IOT_MQTT_CLIENT_ID "MyRaspberryPi" #define AWS_IOT_MY_THING_NAME "MyRaspberryPi" #define AWS_IOT_ROOT_CA_FILENAME "root-CA.crt" #define AWS_IOT_CERTIFICATE_FILENAME "4bbdc778b9-certificate.pem.crt" #define AWS_IOT_PRIVATE_KEY_FILENAME "4bbdc778b9-private.pem.key" // =================================================

Run Sample Applications

  1. Compile the subscribe_publish_sample_app using the included makefile.

    make -f Makefile

    This generates an executable file.

  2. Now run the subscribe_publish_sample_app. You should see output similar to the following:

Your Raspberry Pi is now connected to AWS IoT using the AWS IoT Device SDK for C.