Arduino Blynk Lesson 2 : Notification

Arduino Blynk Lesson 2 : Notification

INTRODUCTION

In this lesson, we will learn on how to get a notification from arduino to the smartphone. This is a simple project designed specially for a beginner who are interested in get started with Internet of Things (IoT).  

HARDWARE PREPARATION

This tutorial use :

  1. Maker UNO
  2. Cytron ESP 8266 WiFi Shield
  3. USB Micro B Cable
  4. Flame Sensor Module

You can make the hardware connection based on the diagram and table below.

Figure 1 : Hardware connection

Sample Code

This is the sample code used for this tutorial. Try it!



  This example shows how to use ESP8266 Shield (with AT commands)
  to connect your project to Blynk.

  WARNING!
    It's very tricky to get it working. Please read this article:
    http://help.blynk.cc/hardware-and-libraries/arduino/esp8266-with-at-firmware

  Change WiFi ssid, pass, and Blynk auth token to run :)
  Feel free to apply it to any other example. It's simple!
 *************************************************************/

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial


#include 
#include 

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

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

// Hardware Serial on Mega, Leonardo, Micro...
//#define EspSerial Serial1

// or Software Serial on Uno, Nano...
#include 
SoftwareSerial EspSerial(2, 3); // RX, TX

// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600

ESP8266 wifi(&EspSerial);

int sensorPin = A0;   // Input pin for the Flame Sensor
int sensorValue = 0;  // Variable to store the value coming from the flame sensor

void setup()
{
  // Debug console
  Serial.begin(9600);

  delay(10);

  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  delay(10);

  Blynk.begin(auth, wifi, ssid, pass);
}

void loop()
{
  Blynk.run();
  sensorValue = analogRead(sensorPin);
  if (sensorValue < 700) {
    Blynk.notify("Fire! Fire!");
  }
 
}

Reference

  1. Blynk - Notification
  2. Flame Detector

Thank you

Thank you for reading this tutorial and we hope it helps your project development. If you have any technical inquiry, please post at Cytron Technical Forum.