Create the Sitewise gateway

An AWS IoT SiteWise gateway connects to data sources to retrieve your industrial data streams. The gateway runs on AWS IoT Greengrass V2 as Greengrass components. For AWS IoT SiteWise a data collection pack and a data processing pack will be deployed. The data collection pack collects data, and then export the data to the Cloud. The data processing pack enables your gateway to process data at the edge.

Data packs use streams from the AWS IoT Greengrass stream manager.

To transfer data to AWS IoT SiteWise in the AWS Cloud the stream SiteWise_Stream is used. You can also provide a custom stream to transfer your data to other destinations.

In this chapter you will learn how to create and configure an AWS IoT SiteWise gateway.

Creating a gateway

In the workshop your gateway is represented by your Cloud9 environment. AWS IoT Greengrass V2 must be installed including the SiteWise packs.

The AWS IoT SiteWise console provides a gateway installation wizard which generates an installer based on your information. The installer creates a Greengrass V2 core device installs the Greengrass V2 core software on your industrial gateway, deploys Greengrass V2 components and creates an AWS IoT SiteWise gateway.

Target gateway configuration

You will configure one OPC-UA data source on your gateway:

  • Node-OPC-UA on localhost port 26543

Create the gateway installer

  1. Navigate to the AWS IoT SiteWise console
  2. Open the navigation pane by choosing the three bars in the upper left corner.
  3. In the navigation pane, choose Gateways.
  4. Under Gateways, choose Create gateway. In case you are prompted to choose a Greengass version, choose Greengrass v2 (Recommended).
  5. Under Gateway name, enter sitewise-workshop-Gateway.
  6. Under Greengrass core device, choose Default setup.
  7. Under Core device name, enter SiteWise-Core.
  8. Choose Next.
  9. Under Edge capabilities, make sure Data processing pack is disabled.
  10. Choose Next.
  11. Choose Add data source.
  12. Under Source name, enter Node-OPC-UA on localhost port 26543.
  13. Do not enter a prefix under Data stream prefix - optional. In case the field is auto populated, delete any prefix.
  14. Under Local endpoint, enter opc.tcp://localhost:26543.
  15. Under Destinations, choose AWS IoT SiteWise.
  16. Choose Add.
  17. Choose Next.
  18. Under Gateway device OS, choose Amazon Linux.
  19. Choose Generate.
  20. Read the hints, and then choose Acknowledge.
  21. When the installer has been created you are prompted to save it.
  22. Save the installer to your local computer.

The naming convention for the installer is As you choose sitewise-workshop-Gateway for your gateway name your installer name is

Upload the installer

Upload the installer to your Cloud9 environment.

  1. Navigate to your Cloud9 environment.
  2. Under FAVORITES, expand /home/ec2-user, and then choose sitewise.
  3. Choose File and then Upload Local Files….
  4. Drag and drop your installer into the Upload Files window.
  5. Close the window when the upload is finished.

Run the installer

You run the installer in a Cloud9 terminal. Before you can run the installer you must make it executable.

In a Cloud9 terminal:

cd ~/sitewise
chmod +x
sudo ./

When the installer has run successfully you should get a message similar to:

Successfully set up Nucleus as a system service

Verify the installation

To verify the installation ensure that the Greengrass core has been created and the components have been deployed.

  1. Navigate to the AWS IoT Greengrass console
  2. Choose Core devices.
  3. Under Greengrass core devices you should find the core device SiteWise-Core.
  4. Choose Deployments.
  5. Choose the link left from SiteWise-Core.
  6. Under Components you should see two SiteWise components:
    • aws.iot.SiteWiseEdgeCollectorOpcua
    • aws.iot.SiteWiseEdgePublisher

Verify the Greengrass core software is running on your industrial gateway.

In a Cloud9 terminal:

ps aux |grep green

The result will show processes which are related to the AWS IoT Greengrass core software and should look similar to:

root     19785  0.0  0.0 124064  3004 ?        Ss   13:38   0:00 /bin/sh /greengrass/v2/alts/current/distro/bin/loader
root     19817 12.3  8.8 3636200 351320 ?      Sl   13:38   0:20 java -Droot=/greengrass/v2 -jar /greengrass/v2/alts/current/distro/lib/Greengrass.jar --setup-system-service false
root     19945  0.0  0.1 133436  6828 ?        S    13:38   0:00 sudo -n -E -H -u ggc_user -g ggc_group -- sh -c java  -cp /greengrass/v2/packages/artifacts/aws.greengrass.StreamManager/2.0.12/aws-iot-device-sdk.jar:/greengrass/v2/packages/artifacts/aws.greengrass.StreamManager/2.0.12/AWSGreengrassGreenlake-1.0-super.jar com.amazonaws.iot.greengrass.streammanager.StreamManagerService
ggc_user 19950  3.7  4.2 3640992 167704 ?      Sl   13:38   0:04 java -cp /greengrass/v2/packages/artifacts/aws.greengrass.StreamManager/2.0.12/aws-iot-device-sdk.jar:/greengrass/v2/packages/artifacts/aws.greengrass.StreamManager/2.0.12/AWSGreengrassGreenlake-1.0-super.jar com.amazonaws.iot.greengrass.streammanager.StreamManagerService
root     19972  0.0  0.1 133436  6768 ?        S    13:38   0:00 sudo -n -E -H -u ggc_user -g ggc_group -- sh -c java -cp /greengrass/v2/packages/artifacts/aws.iot.SiteWiseEdgeCollectorOpcua/2.0.1/IotSiteWiseOpcUaCollector-1.0-super.jar
root     19973  0.0  0.1 133436  6784 ?        S    13:38   0:00 sudo -n -E -H -u ggc_user -g ggc_group -- sh -c java -cp /greengrass/v2/packages/artifacts/aws.iot.SiteWiseEdgePublisher/2.0.1/IotSiteWisePublisher-1.0-super.jar
ggc_user 19978  3.5  4.4 3596592 177516 ?      Sl   13:38   0:04 java -cp /greengrass/v2/packages/artifacts/aws.iot.SiteWiseEdgeCollectorOpcua/2.0.1/IotSiteWiseOpcUaCollector-1.0-super.jar
ggc_user 19982  4.0  3.9 3598928 156700 ?      Sl   13:38   0:05 java -cp /greengrass/v2/packages/artifacts/aws.iot.SiteWiseEdgePublisher/2.0.1/IotSiteWisePublisher-1.0-super.jar
ec2-user 20123  0.0  0.0 119420   992 pts/2    S+   13:41   0:00 grep --color=auto green

Log files

Log files for Greengrass and SiteWise components are stored under the directory /greengrass/v2/logs. In case of errors examine log files in these directory. Note: you must switch to the root user to access the log directory:

sudo su -
cd /greengrass/v2/logs/

Some important log files are:

  • greengrass.log: Logs for AWS IoT Greengrass
  • aws.iot.SiteWiseEdgeCollectorOpcua.log: Logs for the SiteWise component which collects data from OPC-UA servers
  • aws.iot.SiteWiseEdgePublisher.log: Logs for the SiteWise component that sends data to the SiteWise data store in the Cloud.

Continue to the next section to start your OPC-UA server.