Creating an IoT Rule

To get started, head over to AWS IoT and to the region where we have registered our Thing:

  1. From the menu on the left-hand side, click on Act and then click the Create a rule option. On the Create rule screen, we will fill in the details as shown in the following table:

Field

Value

Name

ES_Indexer

Description

Index AWS IoT topic data to Elasticsearch service

SQL version

2016-03-23

Attribute

cast(state.desired.temp as decimal) as temp, cast(state.desired.humd as decimal) as humd, timestamp() as timestamp

Topic filter

$aws/things/Pi3-DHT11-Node/shadow/update

Condition

  1. Once we fill the form in with the information mentioned in the previous table, we should see the rule query statement as demonstrated here:
SELECT cast(state.desired.temp as decimal) as temp, cast(state.desired.humd as decimal) as humd, timestamp() as timestamp FROM '$aws/things/Pi3-DHT11-Node/shadow/update' 
  1. This query selects the temperature and humidity values from the $aws/things/Pi3-DHT11-Node/shadow/update topic and casts them to a decimal or float data type. Along with that, we select the timestamp.
  2. Now, under Select one or more actions, click Add action, and then select Send messages to the Amazon Elastic Service. Click on Configure action.
  1. On the Configure action screen, fill in the details as illustrated here:

Field

Value

Domain Name

pi3-dht11-dashboard

Endpoint

Will get auto selected

ID

${newuuid()}

Index

sensor-data

Type

dht11

IAM role name

iot-rules-role

  1. Once the details mentioned in the table are filled in, click on the Create action button to complete the setup.
  2. Finally, click on Create rule and a new rule should be created.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.98.13