Alert system using W5100S-EVB-Pico and AWS SNS
The IoT core receives the MQTT message sent from W5100S-EVB-Pico, sets a rule, and sends outlier data to SNS to receive email notifications.
1. Concept
Sensor outlier detection alarm.
Set to receive a notification when the value sent from the sensor exceeds the set threshold.
The IoT core receives the MQTT message sent from W5100S-EVB-Pico, sets a rule, and sends outlier data to SNS to receive email notifications.
2. Implementation
1) Connect AWS IoT Core + W5100S-EVB-Pico
Create Thing
- Click "Create things"
- Select "Create single thing"
- The thing name is set to be identifiable.
- Select Automatically generate certificate.
- Create and connect policies for IoT Core use.
- The policy details are as follows.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "iot:Connect",
"Resource": "*"
},
{
"Effect": "Allow",
"Action": "iot:Publish",
"Resource": "*"
},
{
"Effect": "Allow",
"Action": "iot:Receive",
"Resource": "*"
},
{
"Effect": "Allow",
"Action": "iot:Subscribe",
"Resource": "*"
}
]
}
Publish MQTT Message
- We used the SDK that connects RP2040 and AWS, and can be used by following the GitHub link .
- I changed the thing name to the thing name created above.
/* AWS IoT */
#define MQTT_DOMAIN "account-specific-prefix-ats.iot.ap-northeast-2.amazonaws.com"
#define MQTT_PUB_TOPIC "$aws/things/YOUR_THING_NAME/shadow/update"
#define MQTT_SUB_TOPIC "$aws/things/YOUR_THING_NAME/shadow/update/accepted"
#define MQTT_USERNAME NULL
#define MQTT_PASSWORD NULL
#define MQTT_CLIENT_ID "YOUR_THING_NAME"
- The message payload currently being sent by W5100S-EVB-Pico is as follows:
{"temperature":23, "humidity":25}
2) SNS settings
Create Topic
- In the AWS SNS Console window, click Topics > Create topic.
- Select Standard as the Type and set the Name of the Topic.
- FIFO supports only SQS subscription protocol.
Create Subscriptions
- Go to the details page of the topic you created and select create subscription.
- Subscription is where you will receive notifications, and the endpoint is set to email.
- Confirmation is required after creation.
- After creation, a verify email is sent to the corresponding email address. It can be used only after confirmation via email.
- Go to your email and click Confirm subscription
- When you click, the screen below will appear, and when you enter Subscription on SNS, the status of the subscription will change to Confirmed.
Test SNS
- Go to topic and click Publish message
- Enter test message in messgae body and click publish message.
- You can confirm that a test message has been sent to your email.
3) Creation of IoT Core Rule
- Select Message Routing > Rules > Create rule in AWS IoT
- Set rule name
- Enter SQL statement. The format is
- SELECT FROM WHERE
- Triggered when the temperature value is 1 (specific value) or higher.
- Select SNS from rule actions and select the TOPIC you created.
- Create a new role, or select a previously used role.
4) Test
- Since Pico is connected, if you activate the rule created in IoT Core,
- When the conditions are met, a notification is sent to the subscription you have set.