Everything about Internet of Things and more

Blynk Email and Push Notifications tutorial – ESP8266 Arduino Example

In this quick tutorial we are going to learn how to send emails and push notifications from the WiFi ESP8266 module, or any other IoT device, using Blynk Email and Push Notification APIs. For this demonstration we are going to build a simple thermometer project and then setup temperature Alarm points. Whenever the alarms will trigger, an email and a push notification will be sent.

Project difficulty

This project requires low to medium programming knowledge and medium electronics knowledge. To complete this project you will spend minimum 20 minutes.

Required materials and hardware

Blynk Email and Notification - ESP8266 Example (1)

IoT Blynk Email and Push Notifications – Arduino example using ESP8266

At this time, from what I found, the simplest method to send Emails from a ESP8266 WiFi module is by using IoT Blynk platform. By calling Blynk APIs in Arduino code, we can achieve this very simple and fast. If this is your first time when hearing about ESP8266 modules you should first checkout this ESP8266 tutorial. Also if you are into IoT but you never used Blynk read here a complete Blynk tutorial with video examples.

Project setup – step by step

  1. Setup your hardware project following the hookup sketch below (skip this, if you already have a working IoT test environment)
  2. Download and install the Blynk app on your smartphone – Android, IOS
  3. Setup a new Blynk Project on your smartphone – see here how create a Blynk project
  4. Add Email and Notification Widgets on your Blynk project (see images below)
  5. Get the Authorization Token from the Blynk Project
  6. Open Arduino IDE and paste my DHT22 Thermometer sketch example
  7. Upload the sketch into your ESP8266 Module

In the image below you can see Blynk Email and Push Notification Widgets in the widget box, and also dragged on the dashboard. The Email Widgets gives you the possibility to overwrite the email address from the application.

Blynk Email and Notification - ESP8266 Example (2)

The Arduino code is pretty simple. The Arduino example below is made for a prototype using ESP8266 version 01 and DHT22 Temperature and Humidity sensor. The DHT22 is hooked on the GPIO02 and defined as DHTPIN 2. The readings are made in a loop interval of 2,5 seconds, as the DHT22 requires at least 2 seconds to refresh the measurements. Have a look over this code and after that we will continue the explaining:

 * ESP8266 example
 * www.geekstips.com
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
#include <DHT.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "****************************";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "*************";
char pass[] = "*************";

#define DHTPIN 2          // What digital pin we're connected to

// Uncomment whatever type you're using!
//#define DHTTYPE DHT11     // DHT 11
#define DHTTYPE DHT22   // DHT 22, AM2302, AM2321
//#define DHTTYPE DHT21   // DHT 21, AM2301
int alarmPin = 4;
int led1 = 16;
int led2 = 14;
SimpleTimer timer;

void sendSensor(){
  float h = dht.readHumidity();
  float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit

  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");

  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, t);

  // SETUP the ALARM Trigger and Send EMAIL 
  // and PUSH Notification

  if(t > 28){
    Blynk.email("vaduva.ionut.lucian@gmail.com", "ESP8266 Alert", "Temperature over 28C!");
    Blynk.notify("ESP8266 Alert - Temperature over 28C!");

void setup(){
  Blynk.begin(auth, ssid, pass);
  timer.setInterval(2500L, sendSensor);

void loop(){

Nothing so new, nothing so hard. As I promise you, to achieve our goal we just need to add only two new lines:

//Blynk API call for EMAIL sending
Blynk.email("vaduva.ionut.lucian@gmail.com", "ESP8266 Alert", "Temperature over 28C!");
//Blynk API call for NOTIFICATION pushing
Blynk.notify("ESP8266 Alert - Temperature over 28C!");

As you can see in the example above, first line stands for calling the Blynk Email API. Execution is done with 3 parameters: email address, subject and body, pretty much familiar as in many programming languages.

Blynk Email limitation and downsides

Maximum allowed length is 120 symbols for all email + subject + message. However you can increase this limit if necessary by adding following commands to you sketch:


Where XXX is desired max length of your email. For example for ESP you can set this to 1200 max length #define BLYNK_MAX_SENDBYTES 1200. Note that this line must be on top of any of the Blynk includes in your sketch.

The time limit between sending emails is minimum 15 seconds. In case you are using gmail you are limited with 500 mails per day (by google). Other providers may have similar limitations, so please be careful. The Blynk free cloud server gives you a maximum of 100 emails every day.

The second line obviously calls the Notification API which triggers Mobile OS specific notifications. The Blynk Push notification API offers two additional options as follows:

Blynk Push Notifications limitation and downsides

I think that, for most of you, the above limitations will not affect the project flow. Therefore, this is a great way to achieve emails and push notifications, having no costs whatsoever. Even at some point we need to pay a bit to extend the Blynk potential, considering the benefits I really have no problem paying.

If you want to find more about which are the best temperature sensors in Internet of Things projects, read this awesome comparison between DHT22 and DS18B20 sensors.

Hoping that this article inspired you, i kindly invite you share this articlesubscribe my YouTube channel and join the communities on social networks. Please feel free to comment or send suggestions / remarks so i can improve the content quality!

Share on: Facebook Twitter Google+

33 Replies to “Blynk Email and Push Notifications tutorial – ESP8266 Arduino Example”

  1. Maria Nurlela Dabukke says:

    May I know how much is voltage of the breadboard power supply?

    • Hello, the breadboard power supply provides both 5v and 3v3. For ESP you should use 3v3.

  2. Maria Nurlela Dabukke says:

    Where is I can found the complete circuit diagram?


  3. ayu says:

    hello. i would like ask a question.

    i am working my final project which is pet feeder that is controlled by mobile phone apps, which is blynk. and i need the apps to send push notifications to remind the user to feed the pet. example is “feed me!”. and i need the push notification to send at least twice a day. i am very new to c programming and really in need of help. if you could help me feel free to contact me through my email ayuzee.am@gmail.com / charoigne@icloud.com. thnkyou so much. may god bless you.

  4. Faried says:

    Hi! I’m using arduino Uno and esp 8266 wifi module for my project. in Arduino IDE/tools you choose what board? Arduino Uno or Esp8266? Please help me

  5. zainal says:

    hi Vaduva,
    I’ve tried to sketch from you, but when compiling comes the message “C: \ Users \ tya \ Documents \ esp8266 \ sketch_nov08b_notif_suhu_blynk \ sketch_nov08b_notif_suhu_blynk.ino \ sketch_nov08b_notif_suhu_blynk.ino.ino: 8:25: fatal error: SimpleTimer.h: No file or directory



    compilation terminated. ”
    Thank you for the help

    • Make sure that you have installed latest Blynk library. Go to library manager, seach for blynk and install or update it. From what I remember on the fly, I think SimpleTimer.h is included in Blynk.

  6. Sadirbek says:

    I am using ET215 moisture sensor. How can I define my sensor on the code? Is there necessary download library for my sensor?
    Thanks in advance

  7. Radu C. Asandei says:

    Hi Lucian!
    I’ve tried to compile your sketch from above, but it seems that you have used a different DHT library from what I have installed. Please, can you tell me from where I can get/download what you had used?
    Thanks in advance.

  8. Volker says:

    if(t > 28){
    Blynk.email(“vaduva.ionut.lucian@gmail.com”, “ESP8266 Alert”, “Temperature over 28C!”);
    Blynk.notify(“ESP8266 Alert – Temperature over 28C!”);

    Will you get repeated Mails/Notifies, if the temperature remains obove 28?

    • You are right, but this is just for the sake of example. Adjusting your conditions should be straight forward from here

  9. Hariesh says:

    Can i do this using usb mode in blynk. That is without using ESP8266
    and using arduino uno

  10. Mishah says:

    Affascinante esercizio, il primo che ho realizzato usando il mio nuovo DHT22 che funziona alla grande. Tuttavia in principio sono impazzito perché c’è un pò di confusione nello schema elettrico, infatti manca il secondo collegamento di alimentazione alla piccola scheda esp 01, e di conseguenza non mi si accendeva. Poi però mi sono accorto di questo particolare ed ha funzionato tutto alla perfezione. complimenti all’autore.

  11. Abhilasha Jain says:

    Hi ,
    From where can we get the complete circuit diagram? including arduino,esp and DHT sensor.
    Kindly provide the complete circuit diagram.

    Thank you.

  12. Cet says:

    Hi, I did your project, works well. Then I changed the sensor with DS18B20 but I can not get the email alert and any notification. What is wrong with this code? any help would be appreciated

    /* ESP & Blynk */
    #define BLYNK_PRINT Serial

    /* Blynk credentials */
    char auth[] = “hgffffffffffffffffffff”;

    /* WiFi credentials */
    char ssid[] = “zzzzzzzzz”;
    char pass[] = “xxxxxxxxx”;

    /* TIMER */
    SimpleTimer timer;

    /* DS18B20 Temperature Sensor */
    #define ONE_WIRE_BUS 2
    OneWire oneWire(ONE_WIRE_BUS);
    DallasTemperature DS18B20(&oneWire);
    int temp_0;

    void setup()
    Blynk.begin(auth, ssid, pass);
    timer.setInterval(1000L, getSendData);
    Serial.println(” “);

    if(temp_0 > 26){
    Blynk.email(“qqqqqqqq@gmail.com”, ” Alert”, “Temp 26C!”);
    Blynk.notify(” Alert – Temp 26C!”);

    void loop()

    * Send Sensor data to Blynk
    void getSendData()
    temp_0 = DS18B20.getTempCByIndex(0);

    Serial.print(“Temp_0: “);

    Blynk.virtualWrite(10, temp_0); //virtual pin V10


  13. fatina aisya says:

    Hi there,
    Nice sharing. Now i working on ultrasonic sensor with nodemcu. i want to get notify if the distance reach at certain range. how i can use this code to implement as hc-sr04 ?

  14. gert-jan vanhaelewyn says:

    Beste, ik krijg een error met
    SimpleTimer.h: No such file or directory
    en een error ook met dht 11 hoe komt dat?
    mooi project

  15. grefma says:

    can i send email to my smartphone, when i use lokal server?

  16. Karin says:

    hi. i would like ask a question.

    Can you tell me, how to send an email/notification just twice a day ??
    bcause i try your code :
    “//Blynk API call for EMAIL sending
    Blynk.email(“vaduva.ionut.lucian@gmail.com”, “ESP8266 Alert”, “Temperature over 28C!”);
    //Blynk API call for NOTIFICATION pushing
    Blynk.notify(“ESP8266 Alert – Temperature over 28C!”);”

    this code always send the email/notification everytime. And thats too many for me, bcause just in one time it can send 10 or more email/notification.
    Please, Can you Help me ?? >.<

  17. Akshay Kashyap says:

    Why it is so that the notification comes again and again despite of the fact that it is presssed ok?

  18. Illioni says:

    Hi, can you show me how to add blynk notification in arduino uno and nodemcu esp8266? I got stuck on this project. Please help me

  19. Elijah says:

    What IOT protocol is blynk working working with? Thanks

  20. Shahnaz Malik says:

    My name is Shahnaz Malik, I bought mobile from Blynk Company online on 14/12/2019, blynk company called me and said this mobile has a 6 month warranty and you can show it at any Apple store when the phone comes with problems. Should be Within 2 months my mobile battery was swollen, no one would listen to the complaint, if inadvertently if the mobile gets blasted or if I face any problem then who will be responsible Apple company or Blynk company give me the answer.

  21. Adi says:

    Hi Vaduva,
    I’ve tried to sketch from you, but i got a little error on compiling In file included from /Users/adi/Documents/Arduino/libraries/ESP8266WiFi/src/ESP8266WiFi.h:33:0,
    from /Users/adi/Documents/Arduino/email_notification/email_notification.ino:6:
    /Users/adi/Documents/Arduino/libraries/ESP8266WiFi/src/ESP8266WiFiType.h:26:10: fatal error: queue.h: No such file or directory

    compilation terminated.
    exit status 1
    Error compiling for board Arduino Uno. Could you please help me. Thank you

  22. Ignace Vandevelde says:


    I want to send an email fron my esp8266 with a textstring and a value of the batteriestatus (VCC) but I donn’t know what’s the syntax for it to merge both things into the same message. Sending an email with only a txtstring works well here. Btw the function to know the status of the accu is verry pretty done only with a code, super function because otherweise you must adding resistors etc. to your project. Many tanks for your soon answere and tips!

  23. John says:

    Hello. With your code above how to you make it have a high limit so if temp is over the set point a email is sent and then a low limit so then if the temp is below the setpoint an email is sent?

  24. Gary Benna says:

    I am using two esp8266 modules with my Blynk project. One is esp8266-01, the other esp8266-12e. I am getting sensor readings with the -01 and using bridge mode to send them to 12e.
    Bridge1.virtualWrite(V5, aValue); is sent from -01. It is received on the -12e and I assign the widget to V5 and then use
    int pinValue = param.asInt():
    I use Blynk.syncAll(); to update the values.
    I have included the notification widget in the Blynk app and am trying to get a notification if pinValue gets too high or low so I write

    int pinValue = param.asInt():
    if(pinValue 75){
    Blynk.notify(“reading is above 75”);
    I have intentionally set the reading above and below the parameters, but no notification.
    do you have some suggestions?

  25. Rafi says:

    Hello Author, i have project that also using email widget. in my case i want to send some interger data in my email, and this email contain interger data and will sended per week, did i also need rtc module in this kind of project.

    i hope you understand what i said, if you got confuse with what im trying to say please got me on email pliz.

  26. D.G.Ramith Tharaka says:

    Can i get that notification to the mobile phone. Please help me.

  27. D.G.Ramith Tharaka says:

    Can I get that notification to the mobile number

  28. andrea says:

    int alarmPin = 4;
    int led1 = 16;
    int led2 = 14; Hello, great project congratulations can you explain these pins where I find them? Thanks

  29. Samuel Chen Yi Hao says:

    //Blynk API call for NOTIFICATION pushing
    Blynk.notify(“ESP8266 Alert – Temperature over 28C!”);

    Referring to the above, do you know of any methods to notify the user of the variable change of temperature. trying to code similar but not working. Please and thanks in advance

    Blynk.notify(“{DEVICE_NAME} temperature is above 28C at (variable) C”, t);

Leave a Reply

Your email address will not be published. Required fields are marked *