Connecting to AWS IoT Core

Configure an AWS IoT Thing

This section assumes that you have an Amazon Web Services account. Before the MQTT connector can send data to AWS IoT Core, a “Thing” needs to be configured as a recipient of such data. In this example, a single “Thing” is created:

  1. Goto “IoT Core” in your Amazon Web Services console
  2. Under “AWS IoT”, expand menu option “Manage” and select “Things”.
  3. Click on button “Create Things”, select “Create single thing” and click “Next”.
  4. Enter a “Thing” name, for example “mqttconnector1” and click “Next”.
  5. Under “Device certificate”, keep option “Auto-generate a new certificate” selected and click “Next”.
  6. Click on button “Create policy” to create a security policy for the thing. Enter a name, for example “mqttconnector-policy”. In the “Create policy” form, click on “Advanced mode” and paste the following into the policy statement entry field to allow all IoT access (adapt to suit):
{
    "Version": "2012-10-17",
    "Statement": [
        {
        "Effect": "Allow",
        "Action": "iot:*",
        "Resource": "*"
        }
    ]
}
  1. Go back to the “Thing” creation steps and select the new policy.
  2. Click on button “Create thing”.
  3. In the next step, download the certificate and the public and private key files and keep them safe for later use.
  4. Click on “Done”. This concludes the configuration of the “Thing”.
  5. Note down your IoT Core device data endpoint. Click on “Settings” near the bottom of the AWS IoT menu to view the endpoint.

Configure the MQTT client

MQTT clients can be configured manually to connect to AWS IoT Core or with “IoT Assistance”. The following steps describe the steps taken when choosing “IoT Assistance”.

Create an MQTT client with default settings, select the client’s “Configuration” node in the navigation tree, and click the “IoT Assistance” button in the toolbar.

../_images/mqtt-client-iot-assistance.png

This will show the following dialog.

../_images/mqtt-client-iot-assistance-dlg.png

Keep the “AWS” option selected and click “Next”.

../_images/mqtt-client-iot-assistance-dlg2.png

Fill in the required details:

( 1 ) Enter the AWS IoT device endpoint.

( 2 ) Enter the Thing name as configured in AWS IoT Core.

( 3 ) Locate the Thing certificate file previously downloaded.

( 4 ) Locate the Thing certificate’s private key file as previously downloaded.

Finally, click “Finish” ( 5 ) to configure the MQTT client.

You can now review the settings and test the connection.

Note

If the AWS IoT certificate issuer is not trusted by the operating system then either install the certificate or test the connection by checking “Accept any server certificate” in the MQTT client configuration.