Using the AWS IoT device SDKs on a Raspberry Pi - AWS IoT

Using the AWS IoT device SDKs on a Raspberry Pi

The AWS IoT Device and Mobile SDKs help you to connect your devices to AWS IoT easily and quickly. The AWS IoT Device and Mobile SDKs include open-source libraries, developer guides with samples, and porting guides so that you can build innovative IoT products or solutions on your choice of hardware platforms.


Before you start this tutorial, complete the steps in Getting started with AWS IoT Core.

These tutorials provide step-by-step instructions for connecting your Raspberry Pi to the Message broker for AWS IoT using the AWS IoT Device SDK for Embedded C and the AWS IoT Device SDK for JavaScript. After you complete the steps in these tutorials, you can connect to the AWS IoT platform and run the sample applications included with the AWS IoT Device and Mobile SDKs.


To complete this tutorial, you need the following:

Create an AWS IoT thing for your raspberry pi

A thing represents a device whose state is stored in the AWS Cloud. The device's state is stored in a JSON document known as the device's shadow. The shadow is used to both store and retrieve state information. The Device Shadow service maintains a shadow for each device that is registered in AWS IoT.

To register your Raspberry Pi with AWS IoT

  1. On your Raspberry Pi, browse to the AWS IoT console.

  2. In the navigation pane, choose Secure, and then choose Policies.

  3. On the Policies page, choose Create a policy.

  4. On the Create a policy page:

    1. Enter a name for the policy (for example, RaspberryPi-Policy).

    2. For Action, enter iot:*.

    3. For Resource ARN, enter *.

    4. Under Effect, choose Allow, and then choose Create.

      This policy allows your Raspberry Pi to publish messages to AWS IoT.


      These settings are overly permissive. In a production environment narrow the scope of the permissions to that which are required by your device. For more information, see Authorization.

  5. In the console navigation pane, choose Manage, and then choose Things.

  6. Choose Create.

  7. On the Creating AWS IoT things page, choose Create a single thing.

  8. On the Add your device to the device registry page, enter RaspberryPi, and then choose Next.

  9. On the Add a certificate for your thing page, choose Create certificate.

  10. On the Certificate created page, download your private key, device certificate, and a root certificate authority (CA) for AWS IoT. (Choose the Download link for each.) These files are saved in your /home/pi/Downloads directory.

  11. Choose Activate to activate the X.509 certificate, and then choose Attach a policy.

  12. On the Add a policy for your thing page, choose RaspberryPi-policy and then choose Register Thing.