Voiced by Amazon Polly |
Overview
When we do automation in the industry or the field of smart agriculture, we will continuously monitor various parameters such as temperature, humidity, CO2, pressure, and so on. If a particular threshold exists, we will trigger the actuator based on the different parameters this will allow us to boost industrial production or control the climate in agricultural greenhouses.
Whenever some parameters threshold exceeds, we must notify the end users, in this blog we will look at how to include IoT alert notifications using an AWS IoT Rule and SNS. You can use the AWS IoT Rules Engine to describe how data sent to AWS IoT Core interact with AWS services. AWS IoT rules are made up of three parts: a SQL SELECT expression, a topic filtering, and a rule action. Data can be extracted from receiving MQTT messages using the SQL SELECT command. Amazon SNS allows you to deliver notifications to your consumers directly.
Customized Cloud Solutions to Drive your Business Success
- Cloud Migration
- Devops
- AIML & IoT
Creation of SNS Topic and Subscription
Before building an IoT rule, we must first construct an SNS topic and subscription to receive and deliver data to the endpoint specified in the subscription.
- Log into an AWS console, search SNS in the search bar, and navigate to the Amazon SNS service.
- In the Amazon SNS service, in the left corner, click topics, then choose create topic, select type as Standard, input the name IoT_alert leave the other options alone and click create topic. Just a matter of time IoT_alert Topic will be created.
3. In the Amazon SNS service console Choose IoT_alert, which is just before we created.
4. In the IoT_alert topic down below click subscription then click create subscription. In the protocol section select Email.
5. In the Endpoint section enter your email address abc1232323@gmail.com then click create subscription.
6. After creating the subscription, we must confirm with entered email id. So, log on to entered email address and in your inbox, we can see the mail from AWS, click on Confirm subscription link to subscribe to the topic.
Creation of IoT Rule
- Go to Amazon IoT Core, select Message Routing on the left side of the IoT core console, and then click Rules.
- Choose Create Rule, enter IoT_alert_rule as the Rule name, then click Next.
- Select SQL version as 2016-03-23, then enter SELECT * FROM ‘device/12/IoT_alert’ WHERE temperature > 30 on the SQL statement, then click Next.
- In the Rule actions section, select action as simple Notification Service (SNS), then select SNS topic as arn:aws:sns:us-east-1:XXXXXXXXX-IoT_alert which is created in the previous step.
- Choose RAW as the message format, then in the IAM role section, select the create role option, then enter IoT_alert_role and click create.
- Down below click next finally review and click create option, the IoT_alert_rule will be created.
Data Ingestion and Testing
- To ingest the IoT data to AWS IoT core navigate to the AWS IoT core and click MQTT test client choose a publish option and a topic option.
- Enter the topic name as device/12/IoT_alert and message payload as {“temperature”: 27,”humidity”: 60} and click publish, similarly publish the message with different values as {“temperature”:35,”humidity”:65}.
- The second message has a temperature is > 30 so the IoT rule will trigger the SNS to send an email to the subscribed endpoint. Log into the registered email id and we can see the AWS Notification message from the SNS.
Conclusion
This blog taught us how to leverage IoT Rules and SNS for real-time notification. This will be used in many IoT applications for alert notifications when a specific threshold exceeds the typical value. Not only email notifications we can also invoke the different mobile and web application APIs.
Get your new hires billable within 1-60 days. Experience our Capability Development Framework today.
- Cloud Training
- Customized Training
- Experiential Learning
About CloudThat
CloudThat is a leading provider of Cloud Training and Consulting services with a global presence in India, the USA, Asia, Europe, and Africa. Specializing in AWS, Microsoft Azure, GCP, VMware, Databricks, and more, the company serves mid-market and enterprise clients, offering comprehensive expertise in Cloud Migration, Data Platforms, DevOps, IoT, AI/ML, and more.
CloudThat is the first Indian Company to win the prestigious Microsoft Partner 2024 Award and is recognized as a top-tier partner with AWS and Microsoft, including the prestigious ‘Think Big’ partner award from AWS and the Microsoft Superstars FY 2023 award in Asia & India. Having trained 850k+ professionals in 600+ cloud certifications and completed 500+ consulting projects globally, CloudThat is an official AWS Advanced Consulting Partner, Microsoft Gold Partner, AWS Training Partner, AWS Migration Partner, AWS Data and Analytics Partner, AWS DevOps Competency Partner, AWS GenAI Competency Partner, Amazon QuickSight Service Delivery Partner, Amazon EKS Service Delivery Partner, AWS Microsoft Workload Partners, Amazon EC2 Service Delivery Partner, Amazon ECS Service Delivery Partner, AWS Glue Service Delivery Partner, Amazon Redshift Service Delivery Partner, AWS Control Tower Service Delivery Partner, AWS WAF Service Delivery Partner, Amazon CloudFront Service Delivery Partner, Amazon OpenSearch Service Delivery Partner, AWS DMS Service Delivery Partner, AWS Systems Manager Service Delivery Partner, Amazon RDS Service Delivery Partner, AWS CloudFormation Service Delivery Partner, AWS Config, Amazon EMR and many more.
FAQs
1. Will AWS IoT Rule support topic filtering?
ANS: – Yes, using IoT Rule we can select the necessary IoT topic.
2. What are the applications of Amazon SNS?
ANS: – Amazon SNS allows you to deliver notifications to your consumers directly. Amazon SNS sends SMS text messages to over 200 countries, mobile push alerts to Amazon, Apple, Android, and Microsoft devices, and email notifications.

WRITTEN BY Vasanth Kumar R
Vasanth Kumar R works as a Sr. Research Associate at CloudThat. He is highly focused and passionate about learning new cutting-edge technologies including Cloud Computing, AI/ML & IoT/IIOT. He has experience with AWS and Azure Cloud Services, Embedded Software, and IoT/IIOT Development, and also worked with various sensors and actuators as well as electrical panels for Greenhouse Automation.
Comments