Skip to content

Send data to AWS IoT Core ​

This article will introduce how to use the EMQX Neuron to bridge data to AWS IoT through the public network so that you can easily build IoT applications.

Introduction to AWS IoT ​

What is AWS IoT ​

Amazon IoT Core is a hosted cloud platform that makes it easy for connected devices to securely interact with cloud applications and other devices. Amazon IoT can support billions of devices and trillions of messages and can process and securely route them to Amazon Cloud Technologies endpoint nodes and other devices. With Amazon IoT, your applications can track and communicate with all your devices at all times, even when they are not connected.

AWS IoT

Benefits of the AWS IoT platform ​

  1. Broad and deep: AWS has broad and deep IoT services from the edge to the cloud, providing local data collection and analysis capabilities as well as data management and rich analytics integration services on the cloud designed for IoT.
  2. Multiple layers of security: including preventive security mechanisms (such as encryption and access control of device data), continuous monitoring and auditing of security configurations, etc.
  3. Superior AI integration: AWS brings AI and IoT together to make devices smarter. Multiple machine learning frameworks are supported.
  4. Proven at scale: AWS IoT is built on a scalable, secure, and proven cloud infrastructure that scales to billions of different devices and trillions of messages.

Configure AWS IoT ​

The steps below are all performed in the AWS IoT console.

1. Create policy ​

Find Security -> Policy, create a policy named neuron, and write the policy with the following configuration.

AWS IoT create policy
json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "iot:Connect",
      "Resource": "arn:aws-cn:iot:cn-northwest-1:153045624426:client/neuron_*"
    },
    {
      "Effect": "Allow",
      "Action": "iot:Publish",
      "Resource": "arn:aws-cn:iot:cn-northwest-1:153045624426:topic//neuron/aws"
    },
    {
      "Effect": "Allow",
      "Action": "iot:Publish",
      "Resource": "arn:aws-cn:iot:cn-northwest-1:153045624426:topic//neuron/*/write/resp"
    },
    {
      "Effect": "Allow",
      "Action": "iot:Receive",
      "Resource": "arn:aws-cn:iot:cn-northwest-1:153045624426:topic//neuron/*/write/req"
    },
    {
      "Effect": "Allow",
      "Action": "iot:Subscribe",
      "Resource": "arn:aws-cn:iot:cn-northwest-1:153045624426:topicfilter//neuron/*/write/req"
    },
    {
      "Effect": "Allow",
      "Action": "iot:Publish",
      "Resource": "arn:aws-cn:iot:cn-northwest-1:153045624426:topic//neuron/*/read/resp"
    },
    {
      "Effect": "Allow",
      "Action": "iot:Receive",
      "Resource": "arn:aws-cn:iot:cn-northwest-1:153045624426:topic//neuron/*/read/req"
    },
    {
      "Effect": "Allow",
      "Action": "iot:Subscribe",
      "Resource": "arn:aws-cn:iot:cn-northwest-1:153045624426:topicfilter//neuron/*/read/req"
    }
  ]
}

2. Create a thing ​

Go to the AWS IoT control panel, find Manage -> Things, and click Create things to create a thing named neuron.

AWS IoT create thing

Select Auto-generate a new certificate.

AWS IoT generate certificate

After the certificate is created, you need to download the certificate on this page for device two-way authentication.

AWS IoT download certificate

Finally, associate the policy created earlier with the thing.

AWS IoT select policy

3. Lookup the device data endpoint ​

In the Settings tab, get the device data endpoint for device connection.

AWS IoT data endpoint

Configure EMQX Neuron ​

South device ​

We need some south devices to collect data from. Any EMQX Neuron southbound driver will do for this tutorial, for example, the Modbus TCP driver.

Add the modbus-tcp Node ​

Click South Devices -> Add Device to add a node using the Modbus TCP driver. This tutorial will connect to a modbus simulator at port 60502.

Add modbus node in EMQX Neuron dashboard

Create a Group ​

Click the modbus-tcp node to create a group. We set the group name to group and the interval to 1000.

Add a group to the modbus node in EMQX Neuron dashboard

Add Tag ​

Click the created group group to create a tag with the name tag0 and with type INT16.

Add a tag to the modbus node in EMQX Neuron dashboard

Finally, check that the modbus-tcp node is in Connected state.

EMQX Neuron dashboard sourth devices tab showing modbus node connected

North app ​

Add the aws Node ​

Click North Apps -> Add Application to add a node using the AWS IoT application.

Add aws node in EMQX Neuron dashboard

In the Application Configuration tab, configure the aws node with the AWS data endpoint and device certificates.

EMQX Neuron dashboard north apps tab

Once the configuration is submitted, the aws node connects to AWS IoT Core successfully.

aws node connected state in EMQX Neuron dashboard

Subscribe to the modbus-tcp Node ​

Click the aws node, then click Add subscription, select the modbus-tcp node and the group group. Set the data upload topic to /neuron/aws, which is the MQTT topic to publish south device data.

aws node subscribe to modbus node
aws node subscribe list

Monitor Data ​

After subscribing to the group group of the modbus-tcp node, the aws node will begin pushing data to the AWS IoT Core. Click Monitoring, then select the modbus-tcp node and the group group. We see that EMQX Neuron reports a initial value 0 for tag0.

EMQX Neuron dashboard data monitoring tab

In the AWS IoT console, using MQTT test client to subscribe to the /neuron/aws topic. We can check that AWS IoT Core receives the data correctly.

AWS IoT test client sub1

Write Data ​

In the AWS IoT console, use the MQTT test client to send a write request to the topic /neuron/aws/write/req, which writes value 42 to the tag tag0.

AWS IoT test client write

Now we can see that EMQX Neuron updates tag0 correctly in the Data monitoring tab.

EMQX Neuron dashboard data monitoring tab

And AWS IoT Core receives the correct tag data, 42, which is expected.

AWS IoT test client sub2