top of page

Gmail Alert using IOT - Esp8266

Updated: Aug 12

The Internet of Things ( IoT) aims towards making life simpler by automating every small task around us. Alerts play an important role in IoT developments to notify the user about something important. It can be either in the form of Gmail notifications, LED indication / SMS alerts, or any other form.


In this article, we will learn How to get Gmail notifications using NodeMCU Esp8266. The simplest method to send and receive Gmail alerts from an ESP8266 WiFi module is by using the Blynk app.

Hardware Components :


1. Breadboard


breadboard
Breadboard

They are basically a construction base used for prototyping electronic circuits. Breadboards allow us to make quick connections between hardware components, without soldering.


Buy Breadboard from here.


2. Esp8266 NodeMCU


NodeMCU
Esp8266 NodeMCU

It is an open-source development board specially targeted for IoT developments. It is having integrated support for WiFi connection. Also, it is very cost-efficient as well as consumes less power. It allows us to use it as a micro-controller and manipulate input and output.


Buy Esp8266 from here.


3. Ultrasonic Sensor HC-SR04


Ultrasonic Sensor
HC-SR 04 Ultrasonic Sensor

The sensor contains an eye-like structure that acts as a transmitter (T) and receiver (R). The Ultrasonic transmitter transmits an ultrasonic wave that travels in the air and gets reflected towards the Ultrasonic receiver module.


It works with the basic formula for calculating distance in terms of speed and time i.e. ( Distance = Speed × Time ). Here, the time of flight includes the distance traveled back and forth, so we need to divide the time of flight by 2 while calculating the distance. Thus, D = S x T/2 where T is the time taken for the waves to hit the object and reflect. It consists of 4 pins: Vcc ( Power supply ), Trigger ( input pin ), Echo( output pin ), GND (ground).


Buy HC-SR04 Sensor from here.


4. Jumper Wires


jumper wires
Jumper Wires

Jumper wires are the connecting wires that have connector pins at each end, allowing them to be used to connect the two points without soldering. They typically come in three versions - male-to-male, male-to-female, and female-to-female. Here, we will be using male-to-male jumper wires to interface Ultrasonic Sensor with NodeMCU.


Buy Jumper Wires from here.

Softwares :


1. Arduino IDE


Arduino Integrated Development Environment is open-source software that facilitates the development and uploading of codes to the microcontroller. Program written in Arduino IDE is called Sketch. These Sketch files are saved with the file extension ino.


Click on the link to download the software



2. Blynk App


Blynk is an IoT platform that allows you to quickly build user interfaces for controlling and monitoring your hardware projects from your android phones.


Circuit Connections :


circuit diagram
Interfacing Ultrasonic sensor with NodeMCU

Here, connections are pretty simple. The four pins ( VCC, GND, trigger, echo ) of HC SR 04 #Ultrasonic Sensor is connected as mentioned below -


  1. The VCC pin of HC SR 04 is connected to the VCC pin of Esp8266.

  2. GND pin of HC SR 04 is connected to the GND pin of Esp8266.

  3. The trigger pin of HC SR 04 is connected to the D1 pin of Esp8266.

  4. Echo pin of HC SR 04 is connected to the D2 pin of Esp8266.

Blynk App settings :


1. Create a new project.

Blynk App Menu
Blynk App Menu

2. Name your project ( say Gmail ) then select the hardware device ( #NodeMCU in this case ). Here we will be using a WiFi network, so choose the connection type as Wi-Fi

New Project Menu on Blynk App
New Project Menu

Now, click on Create, you will get an authentication token to your id.


3. Go to Widget Box by clicking on the top right corner, Now select gauge settings to measure the distance from the Ultrasonic #Sensor.

Gauge settings on Blynk App
Gauge Settings

Name your gauge as Distance and then select V5 pin as an input pin. Give Label as cm.


4. Now go to notifications and select #gmail.

Notification Settings
Notification Settings

5. Go to Email settings and check your mail-id.

Email Settings
Email Settings

Code :



Note:

  1. Do not forget to change the file extension to .ino(Arduino IDE) file format before you upload the code to #ESP8266 Board.

  2. Change the auth[ ], ssid[ ], pass[ ] as authentication token (received on mail), Wi-Fi Username and Wi-Fi password respectively.

  3. Replace the Blynk. email function parameter in the code with your email id.

  4. Also, you need to install the Esp8266 library and BlynkSimpleEsp8266 library in Arduino IDE before uploading the code to NodeMCU.

  5. For installing Esp8266 : Go to Tools > Board > Boards Manager > Esp8266 > Click on install .

  6. For installing Blynk library: Go to Sketch > Include libraries > Manage libraries > Search for Blynk and press ENTER > Click on install.

Once the hardware connections are completed and the code is written, connect NodeMCU to the system and insert the code. Now, Run the code.


Working :

Circuit Design of Gmail alert using Esp8266
Gmail alert using Esp8266

The distance of the barrier from the sensor is measured and sent to the Blynk app. The gauge on the Blynk app shows distance measured using an ultrasonic sensor. Whenever the distance measured is less than or equal to 10 cm ( <= 10 cm ), an alert message is received via Gmail.


Do watch the video given below to get a better idea through practical implementation.


Video By - Abhishek Goud


Conclusion :


This article gives an overview of #interfacing NodeMCU with an Ultrasonic sensor to get Gmail alerts, depending on the distance measured. This kind of interfacing can be used in many IoT projects and developments including Water level indicator systems, and Smart Containers.

 

See also


1,430 views2 comments

Related Posts

See All
bottom of page