Skip to main content

AWS IoT Core Intergate With EdgeBox RPi 200

Introduction

AWS IoT Core is a service that assists in securely connecting and managing Internet of Things (IoT) devices. It enables devices to communicate with each other and with the cloud, facilitating the development of smart and connected applications. AWS IoT Core streamlines the integration of IoT devices into the broader AWS ecosystem, offering a reliable and scalable platform for building IoT solutions. In this guide, we will discuss how to connect our Edge Box RPi 200 to the AWS IoT cloud.

Getting Start

Before you start this project, you may need to prepare your hardware and software in advance as described here.

Hardware Preparation

Edge Box RPi 200

Software Preparation

Edge Box-200 comes to your hand pre installed raspberry pi OS. If you are booting this device first time please read our Getting Started Wiki

Install Mqtt library

In your terminal type :

sudo pip3 install "paho-mqtt<2.0.0"

Create AWS Account

If you don't have an AWS account, you can easily create one. Please follow this link for guidance on how to set up your account.

Register the device

  • Step 1: Search IoT core and navigate to it.
  • Step 2: Next in the side bar navigate to Manage topic and under All Devices go to Things.
info

What is a Thing? AWS IoT refers to Internet of Things (IoT) devices as "things" on the AWS platform. Each IoT device, such as the Edge Box Device in this context, is represented as a "thing" in AWS. Importantly, once created, the name of a "thing" cannot be changed.

  • Step 3: Next press on Create things
  • Step 4: We are going to create for single EdgeBox Device. So click Create Single Thing.
  • Step 5: Give a Thing name.
  • Step 6: Also A thing type for your reference in the future
info

What is a Thing Type?

Thing types enable you to store descriptions and configuration information that are common to all things associated with the same thing type. This simplifies the management of things in the registry. For instance, you can define a 'Factory_HMI' thing type. For this demonstration we used pi as a thing type.

  • Step 7 : Generate Certificates
  • Step 8: To Attach policies you need to create. click on Create policy
info

AWS IoT Core policies are JSON documents following IAM policy conventions. They support named policies, enabling multiple identities to reference the same policy document. Named policies are versioned for easy rollback. These policies provide control over access to the AWS IoT Core data plane, encompassing operations such as connecting to the AWS IoT Core message broker, sending/receiving MQTT messages, and accessing or updating a thing's Device Shadow.

  • Step 9: Give an appropriate name to the policy and set policy effect Policy action and Policy resources as following.
info

The policy includes:

Effect: Specifies whether the action is allowed or denied.

Action: Specifies the specific action that the policy permits or denies.

Resource: Specifies the resource or resources on which the action is allowed or denied.

  • Step 10: Attach Policy by policy that you made and press Create thing
  • Step 11:Next you can download certificates and keys. Make sure to download Device certificate, Private and Public keys and Root CA certificate.
  • Step 12 : Attach to the thing (Edge Box RPi 200 ) For that go to Security >> Certificates
info

When you create and enroll a certificate independently from an AWS IoT thing, it lacks policies for AWS IoT operations and isn't associated with any thing object. This explains how to establish these connections for a registered certificate. The certificate authenticates the device with AWS IoT for connection. Linking the certificate to a thing resource creates the relationship between the device (via the certificate) and the thing resource. To grant the device permission for AWS IoT actions, such as connecting and publishing messages, it's essential to attach a suitable policy to the device's certificate.

After selecting the thing that you made from Actions drop down menu then press Attach to thing.

Step 13: Attach the policy also.

Test MQTT

To accomplish this, download our test Python file. Ensure that your device certificates, key files (public and private keys), root access file, and this Python file are in the same folder on your Device. Additionally, you need to modify the connection URL.

To do that :

  • Step 01 :Go to Settings

  • Step 02 : Then you will find the URL

  • Step 03 : Replace those file names with yours and run the file

Test the Connection

Go to MQTT test Client under the Test tab and type the topic name to subscribe. In this case it is device/data.

The output is some thing like this. The massage from Edge Box is pop up in the console.

Tech Support & Product Discussion

Thank you for choosing our products! We are here to provide you with different support to ensure that your experience with our products is as smooth as possible. We offer several communication channels to cater to different preferences and needs.

Loading Comments...