Skip to content

pucp/Temp-and-Humidity-Alert-Using-AWS-ESP32

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

alt tag

In this tutorial, we will measure temperature and humidity using Esp32 and Temp-humidity sensor. You will also learn how to send this data to AWS and create mail alert.

Hardware :

  • ESP-32: The ESP32 makes it easy to use the Arduino IDE and the Arduino Wire Language for IoT applications. This ESp32 IoT Module combines Wi-Fi, Bluetooth, and Bluetooth BLE for a variety of diverse applications. This module comes fully-equipped with 2 CPU cores that can be controlled and powered individually, and with an adjustable clock frequency of 80 MHz to 240 MHz. This ESP32 IoT WiFi BLE Module with Integrated USB is designed to fit in all ncd.io IoT products. Monitor sensors and control relays, FETs, PWM controllers, solenoids, valves, motors and much more from anywhere in the world using a web page or a dedicated server.We manufactured our version of the ESP32 to fit into NCD IoT devices, offering more expansion options than any other device in the world! The integrated USB port allows easy programming of the ESP32. The ESP32 IoT WiFi BLE Module is an incredible platform for IoT application development. This ESP32 IoT WiFi BLE Module can be programmed using the Arduino IDE.

  • IoT Long Range Wireless Temperature And Humidity Sensor: Industrial Long Range Wireless Temperature Humidity Sensor. Grade with a Sensor Resolution of ±1.7%RH ±0.5°C .Up to 500,000 Transmissions from 2 AA Batteries.Measures -40°C to 125°C with Batteries that Survive these Ratings.Superior 2-Mile LOS Range & 28 miles with High-Gain Antennas.Interface to Raspberry Pi, Microsoft Azure, Arduino and More

  • Long-Range Wireless Mesh Modem with USB Interface

Software Used:

  • Arduino IDE
  • AWS

Library Used:

  • PubSubClient Library
  • Wire.h
  • AWS_IOT.h

Uploading the code to ESP32 using Arduino IDE:

  • Download and include the PubSubClient Library and Wire.h Library.
  • Download the Zip file of AWS_IoT ,from the given link and after extracting ,paste the library in your arduino library folder.
  • You can get the Arduino code here
  • You must assign your unique AWS MQTT_TOPIC,AWS_HOST,SSID (WiFi Name) and Password of the available network.
  • MQTT topic and AWS HOST can be get inside Things-Interact at AWS-IoT console. alt tag

alt tag

alt tag

  • Before uploading the code add certificate inside AWS_IOT folder to aws_iot_certficates.c,which is done in further steps.
  • Compile and upload the ESP32_AWS.ino code.
  • To verify the connectivity of the device and the data sent, open the serial monitor.If no response is seen, try unplugging your ESP32 and then plugging it again. Make sure the baud rate of the Serial monitor is set to the same one specified in your code 115200.

Serial monitor output.

alt tag

Making the AWS work.

CREATE THING AND CERTIFICATE

  • THING: It is virtual representation od your device.
  • CERTIFICATE: Authenticates the identity of a THING.
  • Open AWS-IoT
  • Click on manage -THING -Register THING. alt tag alt tag
  • Click on - Create single thing. alt tag
  • Give the Thing name and type. alt tag
  • Click on next. alt tag
  • Now your certificate page will open,Click on Create Certificate. alt tag
  • Download these Certificates,mainly private key,the certificate for this thing and root_ca and keep them in separate folder.
  • Inside root_ca certificate click on Amazon root CA1-Copy it-Paste it to notepad and save it as a root_ca.txt file in your certificate folder. alt tag alt tag

Create Policy It defines which operation a device or user can access.

  • Go to AWS-IoT interface ,Click on Secure-Policies. alt tag
  • Click on Create. alt tag
  • Fill all the necessary details such as policy name,Click Create. alt tag
  • Now go back to AWS-IoT interface ,Click on Secure-Certificates and attach the policy created just now to it. alt tag alt tag alt tag

Add Private key,Certificate and root_CA to code.

  • Open your downloaded certificate in your text editor(Notepad++),mainly private key ,root_CA and certificate of thing and edit them as the format of aws_iot_certficates.c inside AWS_IOT folder.
  • Now open your AWS_IoT folder in your arduino library -My Document.Go to C:\Users\xyz\Documents\Arduino\libraries\AWS_IOT\src ,click on aws_iot_certficates.c,open it on editor and paste all the edited certificate their at required place,save it. alt tag

alt tag

alt tag alt tag

Getting Output-

  • Go to test in AWS_IoT console. alt tag
  • Fill your MQTT topic to Subscription topic in your test credential. alt tag
  • Now you can view yor temp and humidity data.

OUTPUT

alt tag

Steps to make mail alerts.

You set up Amazon Simple Notification Service (Amazon SNS) for creating mail alert to receivers address for different temperature and humidity readings.

  • Go to AWS IoT console -Click on Act. alt tag

  • Don't have any rule -Click on create rule. alt tag

  • On this page Name the rule i.e AlertTempEsp32 ,also provide the description(Creating mail alert of Temp and Humidity sensors data). alt tag

  • Now create Rule Query Statement(SQL statement for processing data from source).In this the statement used is

SELECT * FROM '$aws/things/Temp_Humidity_esp32/shadow/update'

  • $aws/things/Temp_Humidity_esp32/shadow/update,Go to AWS IoT Console -Manage-Thing-Click on your created Thing -Interact.

alt tag

  • To choose an action Click on ADD Action. alt tag

  • Select send a message as an SNS push notification. alt tag

  • Now Configure Action selected.for SNS target-choose Create. Enter a name for the SNS topic,such as Temp_Humidity_Esp32Topic.Message Format -Raw . Create role -Temp_Humidity_Esp32TopicRole. alt tag

  • Add Action. alt tag

  • Create rule. alt tag alt tag

  • Create Amazon SNS to send the messages through your Amazon SNS topic to your email inbox.Click on Services .

alt tag

  • Search SNS.Click on SNS alt tag

  • In Amazon SNS -Click on Subscription.Select topic ARN.Protocol-Email -Give your email Address on which alert to be send. alt tag

  • Now click on Create Subscription.

  • After clicking the Create Subscription .You have to confirm Subscription by clicking on the mail ,that is send to your registered mail id.

alt tag

  • Confirm Subscrption link alt tag

OUTPUT

alt tag

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 100.0%