Developer Guide

The AWS Documentation website is getting a new look!
Try it now and let us know what you think. Switch to the new look >>

You can return to the original look by selecting English in the language selector above.

Using the AWS IoT Embedded C SDK

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

Download the AWS IoT Embedded C SDK to your Raspberry Pi from GitHub:

git clone -b release

This will create a directory called aws-iot-device-sdk-embedded-C in the current directory. By default you will be in your user's home directory (/home/pi).

Download mbed TLS to your Raspberry Pi from GitHub.


This link will bring up the potentially unstable development branch by default. We do not recommend using the development branch. For more information about officially released branches see arm MBED.

Copy the contents of the mbed TLS directory into the aws-iot-device-sdk-embedded-C/external_libs/mbedTLS directory.

Sample App Configuration

The AWS IoT Embedded C SDK includes sample applications for you to try. For simplicity, we are going to run the subscribe_publish_sample application. This application illustrates how to connect to the AWS IoT Message Broker and subscribe and publish to MQTT topics.

  1. Follow the instructions on Getting Started with AWS IoT to create an IoT thing, certificate, private key, and IoT policy.

  2. Copy your certificate, private key, and root CA certificate into the aws-iot-device-sdk-embedded-C/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.

  3. Navigate to the aws-iot-device-sdk-embedded-C/samples/linux/subscribe_publish_sample directory. You must configure your personal AWS IoT 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:

    1. Choose Registry.

    2. Choose Things.

    3. choose the thing that represents your Raspberry Pi. On the Details page for the thing, in the left navigation pane, choose Interact.

    4. Copy everything, including ".com", from REST API endpoint.

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

Run the AWS IoT Device SDK for Embedded C sample applications

  1. Compile the subscribe_publish_sample_app using the included makefile.

    make -f Makefile

    This generates an executable file.

  2. 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 Embedded C.