Introduction to AWS IoT Analytics

   Go back to the Task List

  « 5: Configure SageMaker Notebook    7: Analyze Data in Notebook »

6: Publish Messages to the Topic

The device and AWS IoT Core use publish-subscribe based communication model using topics. In this task, you use MQTT client which is part of AWS IoT Core to publish messages to dojoanalyticstopic topic and due to the IoT rule configuration, the messages will be routed to the AWS IoT Analytics data set. Since, you have registered a device, you can also use AWS IoT Device SDK to publish messages. The workshop does not cover the SDK part. You will use MQTT client.

  1. On the AWS IoT Core console, click on Test menu in the left to open MQTT client. Click on the Publish to a topic link.

    Inbound

  2. It moves to the publish topic part of the MQTT client, type in dojoanalyticstopic as the topic name. Copy-Paste the message shown below and click on the Publish to topic button.

    Inbound

{
  "temperature": 40,
  "vibration": 30,
  "pressure": 25
}
  1. The message is published to the AWS IoT Core. Repeat the previous step to publish the following messages one by one.
{
  "temperature": 35,
  "vibration": 20,
  "pressure": 20
}
{
  "temperature": 19,
  "vibration": 18,
  "pressure": 22
}
{
  "temperature": 24,
  "vibration": 30,
  "pressure": 30
}
{
  "temperature": 35,
  "vibration": 21,
  "pressure": 19
}
{
  "temperature": 32,
  "vibration": 22,
  "pressure": 29
}
{
  "temperature": 29,
  "vibration": 33,
  "pressure": 33
}
{
  "temperature": 34,
  "vibration": 20,
  "pressure": 20
}
{
  "temperature": 28,
  "vibration": 23,
  "pressure": 25
}
{
  "temperature": 39,
  "vibration": 40,
  "pressure": 44
}
{
  "temperature": 21,
  "vibration": 22,
  "pressure": 19
}
  1. All the messages got published. Due to IoT rule which is looking for the messages published to the topic dojoanalyticstopic, the rule will pick the messages and route to the AWS IoT Analytics Data Set.

  2. Let’s check the data in the IoT Analytics Data Set. Goto AWS IoT Analytics management console, click on the Data sets menu in the left and click on dojoanalytics_dataset to see the details.

    Inbound

  3. On the next screen, click on the Run now option under the Actions menu.

    Inbound

  4. On the same screen, it will show the data published to the data set. You can see the timestamp has been added by AWS IoT Analytics to the each published message to convert it into a time-series data.

    Inbound

  5. All good. The data is there in the Analytics Data Set. Let’s use Jupyter Notebook to analyze the data.