Skip to content

Alert System Using W5100S-EVB-Pico & AWS SNS

Alert system that operates when the value sent from the sensor exceeds the threshold.

gemma

Published September 14, 2022

60 UCC

7 WCC

14 VAR

Alert System Using  W5100S-EVB-Pico & AWS SNS

Components

Hardware components Software Apps and online services

Project description

1. Concept

Alert System Using  W5100S-EVB-Pico & AWS SNS, 1. Concept
 

Alert system that operates when the value sent from the sensor exceeds the threshold.

Connect sensor to W5100S-EVB-Pico and receive sensor data from IoT core. If the sensor value exceeds the threshold, SNS is triggered through the Rule. You will be notified of the route you have set through SNS.

2. How to make

1) Connect W5100S-EVB-Pico to AWS IoT Core

Create Thing

Click 'Create things'
Click 'Create things'
Select 'Create single thing'
Select 'Create single thing'
Set thing name
Set thing name
new certificate
new certificate

- Create and connect policies for using IoT Core. The policy details are as follows. If you done [Attach policies to certificate] step, you can create thing. And you must save certificate files.

{   
    "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

I used the SDK that connects the RP2040 to AWS, and you can use it 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"

Set up device certificate and keys.
Put the authentication key saved when creating device in [mqtt_certificate.h] file.

uint8_t mqtt_root_ca[] =
"-----BEGIN CERTIFICATE-----\r\n"
"...\r\n"
"-----END CERTIFICATE-----\r\n";

uint8_t mqtt_client_cert[] =
"-----BEGIN CERTIFICATE-----\r\n"
"...\r\n"
"-----END CERTIFICATE-----\r\n";

uint8_t mqtt_private_key[] =
"-----BEGIN RSA PRIVATE KEY-----\r\n"
"...\r\n"
"-----END RSA PRIVATE KEY-----\r\n

Build SDK file, and put the permware in your device.

The message payload currently sent by the W5100S-EVB-Pico is:

{"temperature":23, "humidity":25}
MQTT fx.
MQTT fx.

2) Setting AWS SNS

Create Topic

Click 'Create topic'
Click 'Create topic'

Select type as Standard, and set the topic' name. FIFO type support only SQS.

2. How to make
 

Create Subscriptions

In topic detail page, click 'create subscription'.

2. How to make

Subscription is alert's endpoint.

2. How to make

After subscription creation, a verify email is sent to the corresponding email address. You can only use it after confirming it in the email. Go to the mail and click Confirm subscription.

2. How to make

Test SNS

In topic, Click 'Publish message'.

2. How to make

Enter test message in message body and click 'publish message'

2. How to make

You can check that the test message has been sent to the mail.

2. How to make
 

3) Create IoT Core Rule

Click 'Create Rule' and, set the rule name.

2. How to make
 

SQL statement's structure is:

SELECT  <Attribute> FROM <Topic Filter> WHERE <Condition>

It is set to trigger when the temperature value is greater than 1 (a specific value).

2. How to make

In rule action, select SNS and then select the created topic.

2. How to make

4) Test

If you activate the rule created by IoT Core while the device is connected, you will receive a notification with a subscription set according to the sql statement.

2. How to make

 

Documents

Comments

Comments