MQTT to connect with AWS IoT Core
Steps to connect to AWS IoT Core
- Create an AWS account: Follow the steps shown in AWS getting started
- Create a device in the AWS IoT Core Console:
In the AWS IoT Core Console navigate to Connect one device and follow all the steps.
Note
In the step 1 "Prepare your device" copy the command
[uniquecode]-ats.iot.us-east-1.amazonaws.com, you will need it to configure the host in your syrus destinations file.In the step 3 "Choose a platform and SDK", select Linux/ macOS and Nodejs.
In the step 5 "Run connection kit" click "Continue" button.
Once you complete all the steps to create the device, you can see it in the AWS IoT Console.

- Download the given certificates from AWS
Download an AWS certificate for server authentication.

- Update the device connection policy
In the "Security" menu, choose the "Policies" option and click on the policy shown in the list.

Select the policy version and click on the "Edit versions" button

Update "Resource" in the JSON file and save it as a new version, then go back to the Policies page and select the new version as active.

- Define the destination in the destinations.syrus.conf file
define destination awsmqtt json aws://a2b6cghq3lfdh2-ats.iot.us-east-1.amazonaws.com:8883
client_id="syrus-867698041094437" publish="zenzando/events" subscribe="zenzando/configuration"
commands_pub="zenzando/commands_pub" commands_sub="zenzando/commands_sub"
key_name="Syrus_demo.private.key" cert_name="Syrus_demo.cert.pem" ca_name="AmazonRootCA1.pem"
Note: you need to update your destinations.syrus.conf with your own values.
For more information visit Syruslang MQTT.
- Upload the necessary files on Syrus 4G
Note: If you need to create an instance in the Syrus 4 Management Tool, please go to Application Manager.
In the Syrus 4 Management Tool upload:
{name_device_aws}.cert.pemand{name_device_aws}.private.keyincluded in the connection kit from step 2.{AmazonRootCA1}.pemdownloaded in step 3.configurations.syrus.confanddestinations.syrus.confconfiguration files for syrus.

- Test the connection
In the Syrus Logs, you can see the events (defined in the configurations.syrus.conf file)

In the AWS IoT Console, you can test the connection in "MQTT test client".
- Subscribe to a topic (enter the same publish name specified in the
destinations.syrus.conffile).

- Publish to a topic (enter the same subscribe name specified in the
destinations.syrus.conffile).

In the Syrus Logs, you can see the message published by AWS.

Updated almost 2 years ago
