To get started, head over to AWS IoT and to the region where we have registered our Thing:
- 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 |
- 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'
- 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.
- Now, under Select one or more actions, click Add action, and then select Send messages to the Amazon Elastic Service. Click on Configure action.
- 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 |
- Once the details mentioned in the table are filled in, click on the Create action button to complete the setup.
- Finally, click on Create rule and a new rule should be created.