Documente Academic
Documente Profesional
Documente Cultură
Blynk App
and
NodeMCU Esp8266
Experiment Brief
We want to
2
Materials Required
• Laptop/PC
• Node MCU Esp8266
• Micro-USB cable
• Smart Phone with Blynk App installed
• Led/Buzzer
• 330 ohm resistor
• Breadboard
• Arduino IDE
• Jumper Wires
3
NodeMCU - Introduction
Features:
• Programmable Wi-Fi module.
• Arduino-like (software defined)
hardware IO.
• Can be programmed with
Arduino IDE.
• USB-TTL included, plug & play.
• 10 GPIOs D0-D10
4
NodeMCU PIN Diagram
5
LED Control Process
6
Adding Blynk App
7
Install Arduino IDE 1.8.8
https://www.microsoft.com/en-in/p/arduino-
ide/9nblggh4rsd8?ocid=badge&rtc=1&activetab=pivot:
overviewtab
8
Adding Blynk Library
9
10
11
Check Blynk Board and ESP8266
12
13
14
Adding Blynk Board add-on
https://raw.githubusercontent.com/sparkfun/Ard
uino_Boards/master/IDE_Board_Manager/pack
age_sparkfun_index.json
15
16
17
18
NodeMCU – Adding additional
board URLs
• Go to files and click on the preference in the Arduino
IDE.
• Copy the below code in the Additional boards
manager.
http://arduino.esp8266.com/versions/2.5.0-
beta2/package_esp8266com_index.json
• Click OK to close the preference Tab.
• After completing the above steps, go to Tools and
board, and then select board manager.
• Navigate to esp8266 by esp8266 community and
install the software for Arduino. Once all the above
process been completed we are read to program our
esp8266 with Arduino IDE.
19
NodeMCU – Adding additional
board URLs
20
21
22
23
Arduino/NodeMCU - Programming
25
26
27
Using a Breadboard
28
Setup Blynk App - Steps
• First install the Blynk app from play store and then
sign in.
• After that Press on click on New Project.
• Enter the name of your project (Eg: led).
• Then Select the Board as ESP8266
• Copy the authentication token no. If you want it in
your email you can send it through email also.
29
Setup Blynk App - Steps
• Click on to the create button
• You are on dashboard screen, now. Just click on the button "+"
on the right corner to add widgets to your project.
• Add a simple button and then configure its settings as Digital
pin.(Eg. GPIO13 for D7, refer NodeMCU Pin Diagram)
• Set button as as push type or as a switch
• Then label the Button as ON and OFF in the settings
30
Circuit Diagram
31
NodeMCU PIN Diagram
32
Circuit Setup
33
Code
34
Code
/* Multiline Comment */
// Defines the object that is used for printing
#define BLYNK_PRINT Serial
35
Code
36
Code
37
Code
void loop()
{
Blynk.run();
}
38
Burn the Sketch in NodeMCU
39
Execution
• After uploading the code
• Open the Blynk app in the Phone
• Let it connect to the internet
• Then you would see your dashboard with a button
• Press Play button on the top most right corner of
the app
• Then Press the Button and you would see the LED
Turn ON.
40
Execution
41
Execution
42
IoT Motion Detector
with
Blynk App
and
NodeMCU Esp8266
43
Experiment Brief
We want to
44
Materials Required
• Laptop/PC
• Node MCU Esp8266
• Micro-USB cable
• Smart Phone with Blynk App installed
• Led/Buzzer and Electronic appliance
• 330 ohm, 1 k and 2 k resistor
• Breadboard
• Arduino IDE
• Jumper Wires
• Relay
45
NodeMCU PIN Diagram
46
Passive Infrared (PIR) Motion Sensor
47
Hardware Setup
• The sensor has 3 pins (+5V, GND and Output).
• PIR sensor generates a logic signal of + 3.3V (HIGH)
or 0V (LOW), which is COMPATIBLE with the input
levels of the NodeMCU, which also works with the
3.3V level. The circuit with a level converter is used
to ensure if any other sensor with 5V output is used.
If the sensor generates 3.3V and not 5V as output
you can eliminate the level converter, connecting
NodeMCU Pin (Eg. D1 (GPIO 5)) directly to PIR
Output.
• We have also included a LED at pin (Eg. D7
(GPIO13)), for a local visualization.
48
49
Testing Sensor
/* PIR Motion Detector */
#define ledPin D2 // Input for HC-SR501
#define pirPin D7 // Red LED
50
Testing Sensor
void setup()
{
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(pirPin, INPUT);
digitalWrite(ledPin, LOW);
}
51
Testing Sensor
void loop()
{
pirValue = digitalRead(pirPin);
Serial.println(pirValue);
digitalWrite(ledPin, pirValue);
delay(1); // delay in between reads for stability
}
52
Compile and Burn Code
53
Check Serial Monitor
54
Add Relay and Electronic Appliance
• Attach Relay with NodeMCU
• One connection to VCC
• One connection to GND
• One Output Pin of NodeMCU to IN Pin of Relay
• Attach Relay to Electronic Appliance (Eg. Fan) and
Power Socket
• Connect one wire of Electronic Appliance to
Socket
• Break 2nd wire into 2 pieces and connect 1st
piece from Fan to Relay and 2nd piece from
Relay to Socket
55
56
Update Blynk App
57
Update Blynk App
58
Code
#include <ESP8266WiFi.h>
/* WiFi credentials */
char ssid[] = "YOUR SSID";
char pass[] = "YOUR PASSWORD”;
59
Code
60
Code
void setup()
{
Serial.begin(115200);
delay(10);
Blynk.begin(auth, ssid, pass);
pinMode(ledPin, OUTPUT);
pinMode(pirPin, INPUT);
digitalWrite(ledPin, LOW);
}
61
Code
void loop()
{
getPirValue();
Blynk.run();
}
62
Code
/*********************Get PIR data
**************************************************/
void getPirValue(void)
{
pirValue = digitalRead(pirPin);
if (pirValue)
{
Serial.println("==> Motion detected");
Blynk.notify("T==> Motion detected");
}
digitalWrite(ledPin, pirValue);
}
63
THANK YOU
64