Bridging Data to AWS IoT using Neuron

This article will introduce how to use the 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

1. Create policy

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

AWS IoT create policy

json

  1. {
  2. "Version": "2012-10-17",
  3. "Statement": [
  4. {
  5. "Effect": "Allow",
  6. "Action": "iot:Connect",
  7. "Resource": "arn:aws-cn:iot:cn-northwest-1:153045624426:client/neuron_*"
  8. },
  9. {
  10. "Effect": "Allow",
  11. "Action": "iot:Publish",
  12. "Resource": "arn:aws-cn:iot:cn-northwest-1:153045624426:topic//neuron/aws"
  13. },
  14. {
  15. "Effect": "Allow",
  16. "Action": "iot:Publish",
  17. "Resource": "arn:aws-cn:iot:cn-northwest-1:153045624426:topic//neuron/*/write/resp"
  18. },
  19. {
  20. "Effect": "Allow",
  21. "Action": "iot:Receive",
  22. "Resource": "arn:aws-cn:iot:cn-northwest-1:153045624426:topic//neuron/*/write/req"
  23. },
  24. {
  25. "Effect": "Allow",
  26. "Action": "iot:Subscribe",
  27. "Resource": "arn:aws-cn:iot:cn-northwest-1:153045624426:topicfilter//neuron/*/write/req"
  28. },
  29. {
  30. "Effect": "Allow",
  31. "Action": "iot:Publish",
  32. "Resource": "arn:aws-cn:iot:cn-northwest-1:153045624426:topic//neuron/*/read/resp"
  33. },
  34. {
  35. "Effect": "Allow",
  36. "Action": "iot:Receive",
  37. "Resource": "arn:aws-cn:iot:cn-northwest-1:153045624426:topic//neuron/*/read/req"
  38. },
  39. {
  40. "Effect": "Allow",
  41. "Action": "iot:Subscribe",
  42. "Resource": "arn:aws-cn:iot:cn-northwest-1:153045624426:topicfilter//neuron/*/read/req"
  43. }
  44. ]
  45. }

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 Neuron

South device

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

Add the modbus-tcp Node

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

Add modbus node in 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 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 Neuron dashboard

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

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 plugin.

Add aws node in Neuron dashboard

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

Neuron dashboard north apps tab

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

aws node connected state in 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 Neuron reports a initial value 0 for tag0.

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 Neuron updates tag0 correctly in the Data monitoring tab.

Neuron dashboard data monitoring tab

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

AWS IoT test client sub2