© 2020, Amazon Web Services, Inc. or its affiliates. All rights reserved.
To add a new rule to send an Amazon SNS notification when certain conditions are met in a decoded message,
follow these steps:
1.
Navigate to the
2.
In the navigation pane, choose
Act
. Then, choose
Rules
.
3.
On the Rules page, choose
Create
.
4.
Enter the
Name
as
text_alert
, and provide an appropriate
Description
.
5.
Under
Rule query statement
, enter the following query:
SELECT DevEUI as device_id, "Temperature exceeded 80" as message,
Alert_Temp as temp, Humidity as humidity, Timestamp as time FROM
'project/sensor/decoded' where Alert_Temp > 80
6.
Choose
Add action
.
7.
Choose
Send a message as an SNS push notification
.
8.
Choose
Configure action
.
9.
Under
SNS target
, select
text_topic
from the drop-down.
10.
Select
RAW
under
Message format
.
11.
Under
Choose or create a role to grant AWS IoT access to perform this action
,
choose
Create role.
12.
Enter a name for the role and choose
Add action
.
13.
Choose
Create rule
. You should see a “Success” message, indicating that the rule has been created.
8.5 Configuring IoT Analytics
We will use IoT Analytics to visually display data via graphs if there is a need in the future to do further analysis. To
configure IoT analytics, you will need to create an IoT analytics rule, configure AWS IoT analytics, and configure
Amazon QuickSight. The steps required to perform this configuration are provided in the following sections.
8.5.1 Creating an IoT Analytics Rule
To create an IoT analytics rule, follow these steps:
1.
Navigate to the
2.
In the navigation pane, choose
Act
. Then, choose
Rules
.
3.
On the Rules page, choose
Create
.
4.
Enter the
Name
as
Visualize
, and provide an appropriate
Description
.
5.
Under
Rule query statement
, enter the following query:
SELECT * FROM 'project/sensor/decoded'
6.
Choose
Add action
.
7.
Select
Send a message to IoT Analytics
.
8.
Choose
Configure Action
.
9.
Choose
Quick Create IoT Analytics Resources
.
10.
Under
Resource Prefix
, enter an appropriate prefix for your resources, such as
LoRa
.
11.
Choose
Quick Create
.
12.
Once the
Quick Create Finished
message is displayed, choose
Add action
.
13.
Choose
Create rule
. You should see a “Success” message, indicating that the rule has been created.
8.5.2 Configuring AWS IoT Analytics
To configure AWS IoT Analytics, follow these steps:
1.
Go to the
2.
In the navigation panel, choose
Data sets
.
3.
Select the data set that was generated by the Quick Create in
Creating an IoT Analytics Rule
4.
In the
Details
section,
Edit
the
SQL query
.
5.
Replace the query with:
select Alert_Temp as temp, Humidity as humidity, DevEUI as device_id,
Timestamp as time from LoRa_datastore
6.
Under
Schedule
, choose
Add schedule
.