AWS

This example uses the public Amazon Web Services (AWS) IoT test broker https://aws.amazon.com/free/iot/  for testing. This section is provided as a convenience; Campbell Scientific does not provide technical support for AWS.

Setup AWS IoT

  1. Open a web browser and set up an account at https://aws.amazon.com/free/iot/ .

  2. Go to https://us-west-2.console.aws.amazon.com/iot/ .


    (Click image to expand/collapse display)

  3. Near the bottom of the left menu select Settings. Copy the Endpoint address. It will end in something like iot.us-west-2.amazonaws.com. You will need this later to configure the data logger.

  4. Go to Manage> All Devices > ClosedThings A thing resource is a digital representation of a physical device or logical entity in AWS IoT.. In this case the CR350 is the Thing.

  5. Click the Create Things button.


    (Click image to expand/collapse display)

  6. Select Create single thing.

  7. Click Next.


    (Click image to expand/collapse display)

  8. Give your Thing a name in the Thing name field. Make note of this value, it will also be the MQTT Client ID in the data logger configuration later.

    NOTE:

    Thing name cannot contain spaces.

    CAUTION:

    Each data logger in the network must have a unique MQTT Client ID. Duplicate Client IDs can cause unstable connections, and high data usage over a cellular connection when only a small amount of data is being published.


    (Click image to expand/collapse display)

  9. Click Next.

  10. On the Configure device certificate screen, select Auto-generate a new certificate. Click Next.


    (Click image to expand/collapse display)

  11. On the Attach policies to certificate screen, click Create policy. This will open a new tab.


    (Click image to expand/collapse display)

  12. On the Create policy screen enter a Policy name. Ensure that Allow is set for the Policy effect. In the Policy action and Policy resource fields enter an asterisk * for a wild card. Click Create.


    (Click image to expand/collapse display)

  13. On the Attach policies to certificate screen, select the Policy you created and click Create thing.


    (Click image to expand/collapse display)

  14. On the Download certificates and keys screen save all your certificates and keys. This is the only time you can download the key files for this device. In a secure location, save the device certificate, Public key file, Private key file, and Root CA certificate. They’ll be needed for setting up the data logger. Click Done.


    (Click image to expand/collapse display)

Configure the data logger

  1. On your computer, navigate to the location your certificates and keys are saved.

  2. Rename the AmazonRootCA1.pem file to CAroot.pem.

  3. Connect to your data logger via USB.

    NOTE:

    For a secure TLS setup the certificates and key must be sent over a direct connection. They cannot be sent over IP.

  4. Using ClosedDevice Configuration Utility Software tool used to set up data loggers and peripherals, and to configure PakBus settings before those devices are deployed in the field and/or added to networks. Also called DevConfig., connect to the data logger.

  5. Select the File Control tab and click Send.


    (Click image to expand/collapse display)

  6. Browse to the CAroot.pem file. Click Open.


    (Click image to expand/collapse display)

  7. Select Deployment > TLS.


    (Click image to expand/collapse display)

  8. Set Max TLS connections to 5.

  9. Click Set Private Key and upload the Private key file by browsing to it and clicking Open. The file name will end in private.pem.key.

  10. Click Set Certificate and upload the Certificate by browsing to it and clicking Open. The file name will end in certificate.pem.crt.

  11. Click Apply to save the changes.

  12. Click Connect to reconnect to your data logger.

  13. On the Settings Editor tab, click the MQTT sub-tab.



    (Click image to expand/collapse display)

  14. On the MQTT tab set the following:

    1. MQTT Enable to Enable with TLS or Enable with TLS-Mutual Authentication
    2. MQTT Broker URL to the Endpoint address that you copied, saved, or noted. See Setup AWS IoT step 3.
    3. Enter 8883 for the Port Number.
    4. MQTT Client ID to the Thing name set in Setup AWS IoT step 8.
    5. MQTT Base Topic is the Publish Policy set in Setup AWS IoT step 10.
  15. Click Apply to save the changes.

Program the data logger

Use MQTTPublishTable() within a DataTable/EndTable declaration to publish stored data via MQTT. See the CRBasic Editor help for detailed instruction information and program examples: https://help.campbellsci.com/crbasic/cr350/ .

DataTable(Five_Min,True,-1)

DataInterval(0,5,Min,10)

Average(1,Temp_C,FP2,False)

Minimum(1,BattV,FP2,False,False)

Publish every 5 min in CSJSON format. The last three parameters are optional to specify longitude, latitude, and altitude. Here we use NaN as placeholders for these values.

MQTTPublishTable(0,0,5,Min,1,NaN,NaN,NaN)

EndTable

Five minutes is the fastest recommended publishing interval in order to ensure that ingestion and processing of data sent to the MQTT broker are completed before new data is received.

Verify data in AWS IoT

  1. In AWS IoT click MQTT test client > Subscribe to a topic.

  2. Enter a # symbol (wildcard) in the Topic filter field. Click Subscribe.


    (Click image to expand/collapse display)

  3. Confirm data is being received in the Subscription area at the bottom of the screen.