Integrate data into SiteWise Edge using an MQTT-enabled, V3 gateway
This tutorial guides you through integrating third-party devices and sensors that use MQTT messaging protocol with the AWS IoT SiteWise MQTT-enabled, V3 gateway. You will learn how to set up an AWS IoT SiteWise edge gateway to collect and monitor data from your MQTT-enabled devices. AWS IoT SiteWise enables you to collect, process, and monitor industrial equipment data. Use SiteWise Edge capabilities to optimize industrial IoT operations, and transform raw data into actionable insights.
In this tutorial, we use data from a wind farm demonstration to illustrate key concepts. After you become familiar with the process, you can repeat the tutorial with your own data.
After you complete this tutorial, you can do the following items:
-
Set up and configure an MQTT-enabled, V3 gateway to receive data from industrial devices
-
Process and validate incoming MQTT messages from your equipment at the edge
-
View device data in AWS IoT SiteWise using a third-party visualization platform
-
Send processed data from your edge gateway to the AWS Cloud to enable centralized storage and further analysis
Additionally, you can leverage your edge gateway capabilities by connecting to other AWS IoT services to perform the following tasks:
-
Configure AWS IoT rules to route data to services like Amazon S3
, Amazon Timestream , and AWS Lambda . -
Use AWS IoT Device Defender
to remotely manage and update your gateway configurations. -
Implement secure device authentication and authorization using AWS IoT security features. For more information, see AWS IoT security in the AWS IoT Developer Guide.
-
Create automated alerts and notifications based on equipment data. For more information, see Rules for AWS IoT in the AWS IoT Developer Guide.
Note
This tutorial references third-party services, tools, and documentation. AWS isn't a vendor or supplier for any third-party products or services, and can't guarantee the accuracy of information from external providers. Evaluate and validate all third-party tools before deployment.
Topics
Prerequisites
To complete this tutorial, you need the following:
-
An AWS account. If you don't have one, see Set up an AWS account.
-
An AWS Identity and Access Management (IAM) user with administrator permissions. For more information, see Identity and access management for AWS IoT SiteWise.
-
The latest version of Python installed on your device.
Important
This tutorial requires the use of resources created in the Ingest data tutorial. You must complete it before proceeding with this tutorial.
Step 1: Create an AWS IoT policy
This tutorial uses the AWS IoT policy you created in the Ingest data tutorial. This policy sets the security rules for your devices and creates a digital representation of your external devices and sensors in AWS IoT. The policy allows your third-party devices to send data to AWS IoT Core using MQTT (Message Queuing Telemetry Transport). For more information about MQTT messages, see What is MQTT?
This policy enables your AWS IoT devices to establish connections and to communicate with device shadows using MQTT messages. To interact with device
shadows, your AWS IoT things publish and receive MQTT messages on topics that start with $aws/things/
. This policy incorporates a thing policy variable known as thing-name
/shadow/${iot:Connection.Thing.ThingName}
. This variable substitutes the connected
thing's name in each topic. The iot:Connect
statement sets limitations on which devices can establish connections, ensuring that the thing policy variable can only substitute names starting with SiteWiseTutorialDevice
.
For more information, see Thing policy variables in the AWS IoT Developer Guide.
Note
This policy applies to things whose names start with SiteWiseTutorialDevice
. To use a different name for your things, you must update the policy accordingly.
Step 2: Create and configure an AWS IoT thing
In this step, register your edge device as an AWS IoT thing and generate your thing’s certificates and keys needed for secure communication with AWS IoT SiteWise Edge. This process establishes the foundation for your device to send third-party data through your MQTT-enabled, V3 gateway.
After completing these steps, you can securely connect your device to AWS IoT SiteWise Edge. You created a local directory to store your certificates and keys you generated for MQTT authentication. Your device is registered as an AWS IoT thing in the AWS IoT console
Step 3: Configure your SiteWise Edge MQTT-enabled, V3 gateway
In this step, create your AWS IoT SiteWise Edge MQTT-enabled, V3 gateway and configure it to receive data from the EMQX broker. The gateway acts as a bridge between your devices and AWS IoT. This allows you to process data locally at the edge before sending it to the AWS Cloud. This configuration reduces bandwidth and decreases cloud processing delays.
Step 4: Install SiteWise Edge gateway software
To install the gateway software, use the installer package that you downloaded in the previous step. The installation process configures the necessary components, starts the Greengrass core service, and registers your device with AWS IoT Greengrass. After installation is complete, verify that your gateway appears in the AWS IoT SiteWise console
For detailed instructions, see Install the AWS IoT SiteWise Edge gateway software on your local device.
Step 5: Configure the EMQX broker to connect to external applications
Note
You must have deployed your SiteWise Edge MQTT-enabled, V3 gateway before proceeding. The gateway provides the necessary infrastructure and security settings required for configuring the EMQX broker. The broker configuration will fail without an active gateway deployment.
Configure the EMQX broker to enable secure communication between your IoT devices and external applications. The EMQX broker functions as a central messaging hub that routes data between your IoT devices, gateway, and applications. The EMQX broker ensures reliable message delivery on your gateway and connected applications at the edge. For more information, see Connect external applications to the EMQX broker.
To configure the EMQX broker
-
Set up the EMQX broker. For detailed configuration instructions, follow Steps 1-14 in Update the EMQX deployment configuration for authentication.
-
Set up MQTT topics for wind farm monitoring. For more information on MQTT requirements, see MQTT topic requirements.
-
CPU Usage:
SiteWiseTutorialDevice/cpu
-
Memory Usage:
SiteWiseTutorialDevice/memory
-
Timestamp:
SiteWiseTutorialDevice/timestamp
-
-
Review your configuration and complete the deployment.
-
Choose Confirm to save your settings.
-
Choose Next until you reach the Review step.
-
On the Review page, choose Deploy.
-
Wait for the deployment to complete successfully before proceeding.
-
-
Prepare messages using the payload format to send to the EMQX broker. For more information about structuring payloads, see Update the EMQX deployment configuration for authentication.
-
Implement the following security measures:
-
Use Transport Layer Security (TLS) encryption (port 8833) to protect data in transit. For more information, see Configure TLS for secure connections to the EMQX broker on AWS IoT SiteWise Edge.
-
Set up username and password authentication to verify device identities. This security measure helps protect your data, and ensures only authorized devices can connect to your system. For more information, see Enable username and password authentication.
-
EMQX allows you to create authorization rules based on identifiers such as username, IP address, or client ID. This is useful for controlling access to your data. For more information, see Set up authorization rules for AWS IoT SiteWise Edge in EMQX.
After successful deployment, your EMQX broker is configured and ready to securely connect with external applications.
Note
The payload format must follow a specific structure for AWS IoT SiteWise Edge to properly process and ingest your data. For more information about the required structure, see JSON payload structure.
Example: Add CPU, memory, and timestamp JSON payloads
CPU JSON payload
{ "propertyAlias": "SiteWiseTutorialDevice/cpu", "propertyValues": [ { "quality": "GOOD", "timestamp": { "offsetInNanos": 0, "timeInSeconds": 1753206441 }, "value": { "integerValue": 45.2 } } ] }
Memory JSON payload
{ "propertyAlias": "SiteWiseTutorialDevice/memory", "propertyValues": [ { "quality": "GOOD", "timestamp": { "offsetInNanos": 0, "timeInSeconds": 1753206441 }, "value": { "integerValue": 67.8 } } ] }
Timestamp JSON payload
{ "propertyAlias": "SiteWiseTutorialDevice/timestamp", "propertyValues": [ { "quality": "GOOD", "timestamp": { "offsetInNanos": 0, "timeInSeconds": 1753206441 }, "value": { "integerValue": 23.5 } } ] }
Note
Each JSON payload must be published separately as an individual message. Don't combine multiple property values into a single message. Send each CPU, memory, and timestamp payload as its own distinct MQTT publication.
The payload defines the required JSON structure that your IoT devices must use to send device data through the EMQX broker to SiteWise Edge. This format ensures that AWS IoT SiteWise can identify your devices and process the sensor readings. After you implement these configurations and payload structures, your wind farm monitoring system is ready to collect and process data.
Step 6: Publish data with Mosquitto
After creating your MQTT-enabled, V3 gateway, configure Eclipse Mosquitto to send test data to SiteWise Edge. Mosquitto is an open-source MQTT message broker that uses the MQTT protocol for lightweight messaging between devices. The Mosquitto client allows you to publish messages to MQTT topics, simulating data from wind farm sensors. Using Mosquitto, simulate device data without requiring any third-party services or additional equipment. For more information, see documentation
Use Mosquitto CLI client to test the SiteWise Edge EMQX broker
-
Install Mosquitto on your local device. For detailed instructions, see Download Mosquitto
on the official Eclipse Mosquitto website. -
For more information about connecting external applications to transfer industrial data, see Connect external applications to the EMQX broker.
Important
Ensure that the MQTT connection settings you configure here match the settings used in Mosquitto publish command. The host must be the IP address or hostname of your SiteWise Edge gateway. The port is typically 1883 (or 8883 if using SSL/TLS).
Use Mosquitto to publish test data. Open a command line and run the following commands:
Example: CPU property
mosquitto_pub -h localhost -p 1883 -t "SiteWiseTutorialDevice/cpu" -m '{ "propertyAlias": "SiteWiseTutorialDevice/cpu", "propertyValues": [ { "quality": "GOOD", "timestamp": { "timeInSeconds": 1753206441, "offsetInNanos": 0 }, "value": { "integerValue": 45.2 } } ] }'
Example: Memory property
mosquitto_pub -h localhost -p 1883 -t "SiteWiseTutorialDevice/memory" -m '{ "propertyAlias": "SiteWiseTutorialDevice/memory", "propertyValues": [ { "quality": "GOOD", "timestamp": { "timeInSeconds": 1753206441, "offsetInNanos": 0 }, "value": { "integerValue": 72.1 } } ] }'
Example: Timestamp property
mosquitto_pub -h localhost -p 1883 -t "SiteWiseTutorialDevice/timestamp" -m '{ "propertyAlias": "SiteWiseTutorialDevice/timestamp", "propertyValues": [ { "quality": "GOOD", "timestamp": { "timeInSeconds": 1753206441, "offsetInNanos": 0 }, "value": { "integerValue": 1683000000 } } ] }'
Note
The use of localhost
as the EMQX broker address is for demonstration purposes only. In production environments or when connecting from external devices, you must use the appropriate EMQX broker address for your specific deployment configuration. For detailed connection instructions, see Connect an application to the EMQX
broker on AWS IoT SiteWise Edge.
Step 7: Specify destinations
In this step, specify destinations to determine where to direct your source data. Use AWS IoT SiteWise with Amazon S3 buffering as your destination. This option provides a scalable way to store and process your IoT data.
Step 8: Specify path filters
In this step, configure path filters to specify which MQTT topics to monitor for your wind farm device data.
Path filters follow the MQTT topic wildcard specification, which supports two special characters:
-
+
– This symbol represents a single-level wildcard, which matches any string at a single level. -
#
– This symbol represents a multi-level wildcard, which matches any number of levels in the topic hierarchy.
Note
For more information about other path filters, see Special characters in path filter names.
Step 9: Configure your AWS IoT resources
In this step, create the necessary AWS IoT SiteWise asset models and assets to represent your simulated third-party devices and enable data ingestion through your edge gateway.
Before starting this step, you should have completed steps 3 to 8 in the Ingest data tutorial. These steps establish the foundational components to integrate your third-party data through the MQTT-enabled V3 gateway. You also set up rules that define how your sensor data flows into AWS IoT SiteWise, and run a device client script that simulates industrial wind farm data.
To validate your AWS IoT resource configuration
-
Use the following AWS CLI command to verify you created and properly configured your SiteWise Tutorial Device Model and SiteWise Tutorial Device Fleet Model:
aws iotsitewise describe-asset-model --asset-model-id
your-device-model-id
Use the following AWS CLI command to retrieve your asset models' ID:
aws iotsitewise list-asset-models
-
Use the following AWS CLI command to verify you created and properly configured your SiteWise Tutorial Device 1 asset and SiteWise Tutorial Device Fleet 1 asset:
aws iotsitewise describe-asset --asset-id
your-asset-id
Use the following AWS CLI command to retrieve your assets' ID:
aws iotsitewise list-assets
Step 10: Visualize your data
Set up the open-source version of Grafana to visualize your wind farm device data. Grafana is a visualization platform that displays your real-time operational data. These dashboards help you track operational efficiency and identify maintenance needs across your infrastructure. For more information about integration, see Integrate AWS IoT SiteWise with Grafana.
To setup Grafana
-
For instructions to download and install the latest version of Grafana, see Install Grafana
on the official Grafana website. -
For detailed configuration instructions specific to your operating system, see Configure Grafana
on the official Grafana website. -
Configure the AWS IoT SiteWise data source. This allows you to set up the AWS IoT SiteWise plugin on your Grafana server. For detailed instructions about how to use the plugin, see Connect to an AWS IoT SiteWise data source in the Amazon Managed Grafana User Guide.
Important
Ensure you have the latest version of Grafana for compatibility with the AWS IoT SiteWise data source.
After completing these steps, you can build and customize Grafana dashboards to display your wind farm's operational metrics. This enables you to track and analyze your wind farm performance at the edge in real time.
Note
While this tutorial uses the open-source version of Grafana, AWS also offers Amazon Managed Grafana for production environments. Amazon Managed Grafana is a fully managed service that eliminates the need to set up, configure, and maintain your own Grafana servers.
Consider upgrading to Amazon Managed Grafana when you're ready to scale your solution. For detailed instructions on how to connect your SiteWise data to Grafana, see the Visualize and share data in Grafana tutorial.
You have completed the tutorial. In this procedure, you configured AWS IoT SiteWise Edge to integrate third-party device data using an MQTT-enabled, V3 gateway. This setup allows you to collect, process, and visualize industrial equipment data at the edge, reducing latency and operational costs. By using the wind farm demo, you collected and processed operational metrics like CPU and memory usage data through your MQTT-enabled, V3 gateway.
To enhance your IoT solution, consider exploring advanced features like anomaly detection by leveraging Detect anomalies with Lookout for Equipment, or integrating with other AWS services like Amazon QuickSight in the Amazon QuickSight User Guide for advanced analytics.
Step 11: Clean up resources after the tutorial
After you complete this tutorial about integrating data into AWS IoT SiteWise Edge, clean up your resources to avoid incurring additional charges.
To delete hierarchical assets in AWS IoT SiteWise
-
Navigate to the AWS IoT SiteWise console
. -
In the left navigation pane, choose Assets.
-
When you delete assets in AWS IoT SiteWise, you must first disassociate them.
Complete the following steps to disassociate your device assets from your device fleet asset:
-
Choose your device fleet asset (SiteWise Tutorial Device Fleet 1).
-
Choose Edit.
-
Under Assets associated to this asset, choose Disassociate for each device asset associated to this device fleet asset.
-
Choose Save.
Note
The device assets are no longer organized as a hierarchy now.
-
-
Choose your device asset (SiteWise Tutorial Device 1).
-
Choose Delete.
-
In the confirmation dialog, enter
Delete
, and then choose Delete. -
Repeat steps 4 through 6 for each device asset and the device fleet asset (SiteWise Tutorial Device Fleet 1).
To delete hierarchical asset models in AWS IoT SiteWise
-
Navigate to the AWS IoT SiteWise console
. -
Delete your device and device fleet assets.
-
In the left navigation pane, choose Models.
-
Choose your device fleet asset model (SiteWise Tutorial Device Fleet Model). You can't delete a model if you have assets that were created from that model.
When deleting hierarchical asset models, start by deleting the parent asset model first.
-
Choose Delete.
-
In the confirmation dialog, enter
Delete
, and then choose Delete. -
Repeat steps 4 through 6 for your device asset model (SiteWise Tutorial Device Model).
To disable or delete a rule in AWS IoT Core
-
Navigate to the AWS IoT console
. -
In the left navigation pane, choose Message routing, and then choose Rules.
-
Select your rule and choose Delete.
-
In the confirmation dialog, enter the name of the rule and then choose Delete.
To delete an Amazon S3 bucket
-
Navigate to the Amazon S3 console
. -
In the left navigation pane, choose General purpose bucket.
-
In the buckets list, select the option button next to the bucket you created, and then choose Empty at the top of the page.
-
In the confirmation dialog, confirm the deletion, and then choose Empty.
-
After the bucket is empty, choose Delete to delete the bucket.
-
In the confirmation dialog, enter the name of your bucket to confirm deletion.
-
Choose Delete bucket.
To delete a SiteWise Edge gateway
-
Navigate to the AWS IoT SiteWise console
. -
In the left navigation pane, choose Edge gateways.
-
Under Gateways, choose the gateway you created for this tutorial. For example,
SiteWise Tutorial Device Gateway
. -
Choose Delete.
-
To confirm you want to delete the gateway, type
Delete
in the confirmation dialog, and then choose Delete in the window that appears.
To delete your IoT thing
-
Navigate to the AWS IoT console
. -
In the left navigation pane, choose Manage, then choose Things.
-
Select the IoT thing you created for this tutorial. For example,
SiteWiseTutorialDevice1
. -
Choose Delete.
-
In the confirmation dialog, enter the name of the thing, and then choose Delete.
To uninstall AWS IoT Greengrass Core
Uninstall the AWS IoT Greengrass Core software from your local device. For detailed instructions, see Uninstall the AWS IoT Greengrass Core software in the AWS IoT Greengrass Developer Guide, Version 2.
Important
Uninstalling Greengrass removes all local configurations and data. Ensure you've backed up any important information before proceeding.
(Optional) To delete third-party resources
After completing this tutorial, consider shutting down any external resources you created. This helps to prevent incurring charges from third-party providers.
Additional resources
Refer to the following resources for more information: