NODEMCU 1.0 (ESP8266) CONTROLLED RELAY USING BLYNK (OVER THE WEB)

38,327

83

28

Introduction: NODEMCU 1.0 (ESP8266) CONTROLLED RELAY USING BLYNK (OVER THE WEB)

About: MY NAME IS P.STEVEN LYLE JYOTHI AND I AM 17 YEARS OLD.

HI GUYS MY NAME IS P STEVEN LYLE JYOTHI AND THIS IS MY FIRST INSTRUCTABLE ON HOW TO CONTROLL RELAYS BY NODEMCU ESP8266-12E VIA BLYNK THROUGH THE INTERNET

SO LETS GET STARTED

SORRY FOR MY BAD ENGLISH

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: THE THINGS YOU WILL NEED

1. NODEMCU ESP8266-12E (http://www.ebay.in/itm/Amica-NodeMcu-Lua-ESP8266-C...)

2. 4CH RELAY (http://www.ebay.in/itm/4-Channel-Relay-Board-Modul...)

3. SOME WIRES

4. 5V POWER SUPPLY 1AMP

5.SOLDERING IRON

6.ANDROID DEVICE WITH INTERNET

7.PC WITH INTERNET

8.BLYNK APP (https://play.google.com/store/apps/details?id=cc.b...)

Step 2: THE BLYNK APP

OPEN THE BLYNK APP

1. CLICK ON CREATE NEW PROJECT

2.NOW SELECT BOARD NODEMCU =>CONNECTION WIFI (YOU WILL GET A AUTH TOKEN TO YOUR EMAIL COPY THE TOKEN AND KEEP ASIDE YOU WILL NEED THE TOKEN WHILE WRITING THE CODE IN ARDUINO)

3.NOW CLICK ON THE (+) ICON

4.NOW SELECT BUTTON

5.ADD UPTO FOUR BUTTONS

6. NOW SELECT EACH BUTTON AND CHANGE PIN TO THE FOLLOWING

BUTTON 1 (D1) / BUTTON 2 (D2) /BUTTON 3 (D3) / BUTTON 4 (D4)

Step 3: PROGRAMMING THE NODE MCU

DOWNLOAD ARDUINO

STEP1.OPEN ARDUINO

STEP2. GO TO FILE=>PREFERNCES=>ADDITIONAL BOARD MANAGERS URL=>PASTE THIS LINK(http://arduino.esp8266.com/stable/package_esp8266c...)

STEP3.GO TO TOOLS=>BOARDS=>BOARD MANAGER

NOW IN BOARD MANAGER SEARCH "ESP8266"

YOU WILL GET "esp8266 by ESP8266 COMMUNITY" IN THE LIST

INSTALL THE LATEST VERSION IN MY CASE V2.3.0

STEP4. 1.GO TO SKETCH=>INCLUDE LIBRARIES=>MANAGE LIBRARIES

2.NOW IN MANAGE LIBRARY SEARCH "BLYNK"

3.AND INSTALL THE "Blynk by volodysmr shymansky"

STEP5. NOW GO TO TOOLS=>BOARD=>NODEMCU V1.0 (ESP8266-12E)

NOW GO TO TOOLS=>PROGRAMMER=.ARDUINO ISP

STEP6. UPLOAD THIS (https://github.com/stevenchanti/P.STEVEN-LYLE-JYOT...) CODE TO YOUR NODEMCU

===================================================================================

YOU HAVE TO CHANGE SOME THINGS IN CODE LIKE SSID AND PASSWORD OF YOUR NETWORK AND PASTE YOUR AUTHENTICATION TOKEN WHICH YOU GOT IN EMAIL

Step 4: SOLDERING THE WIRES

SOLDER THE VIN OF THE NODEMCU TO THE VCC OF THE RELAY BOARD

SOLDER THE GND OF THE NODEMCU TO THE GND OF THE RELAY BOARD

SOLDER THE D1 OF THE NODEMCU TO THE IN1 OF THE RELAY BOARD

SOLDER THE D2 OF THE NODEMCU TO THE IN2 OF THE RELAY BOARD

SOLDER THE D3 OF THE NODEMCU TO THE IN3 OF THE RELAY BOARD

SOLDER THE D4 OF THE NODEMCU TO THE IN4 OF THE RELAY BOARD

Step 5:

Microcontroller Contest 2017

Participated in the
Microcontroller Contest 2017

Be the First to Share

    Recommendations

    • Trash to Treasure Contest

      Trash to Treasure Contest
    • Raspberry Pi Contest 2020

      Raspberry Pi Contest 2020
    • Wearables Contest

      Wearables Contest

    28 Discussions

    0
    MazharS6
    MazharS6

    Question 1 year ago on Step 4

    Why my relay automatically gets turned on Reboot of nodemcu?

    1
    KegRaider
    KegRaider

    Answer 1 year ago

    Hi MazharS5,

    I'm not sure if you have already worked it out, but here goes. I needed the exact same thing, but with my 8 channel relay board. The NodeMCU naturally brings the outputs high unless you are using pullup resistors. Now you can go and solder in some resistors, or do what I did and just modify the code a bit. Add this below the "Serial.begin" bit.

    [code]
    pinMode(D0,OUTPUT); // Relay 1
    pinMode(D1,OUTPUT); // Relay 2
    pinMode(D2,OUTPUT); // Relay 3
    pinMode(D3,OUTPUT); // Relay 4
    pinMode(D4,OUTPUT); // Relay 5
    pinMode(D5,OUTPUT); // Relay 6
    pinMode(D6,OUTPUT); // Relay 7
    pinMode(D7,OUTPUT); // Relay 8
    pinMode(D8,OUTPUT); // Unused
    digitalWrite(D0,HIGH); // Relay 1
    digitalWrite(D1,HIGH); // Relay 2
    digitalWrite(D2,HIGH); // Relay 3
    digitalWrite(D3,HIGH); // Relay 4
    digitalWrite(D4,HIGH); // Relay 5
    digitalWrite(D5,HIGH); // Relay 6
    digitalWrite(D6,HIGH); // Relay 7
    digitalWrite(D7,HIGH); // Relay 8
    digitalWrite(D8,HIGH); // Unused
    [/code]

    Now, in your BLYNK code, the following mappings need to be in place:
    Relay1 = GP16
    Relay2 = GP5
    Relay3 = GP4
    Relay4 = GP0
    Relay5 = GP2
    Relay6 = GP14
    Relay7 = GP12
    Relay8 = GP13

    I have every button mapping set to "Switch" mode, and the output of every GP output as 1 in the first box, and 0 in the second.

    Upon rebooting or removing power to the NodeMCU, the next startup the relays all click for a microsecond, then are in the off state. You can use Blynk to turn them on at will then. Hope this helps you, and others.

    0
    SSBMAN
    SSBMAN

    Reply 3 months ago

    I was having same problem with nodemcu and four relay board. Your codes, definitely solved problem. TNX.

    0
    KegRaider
    KegRaider

    Reply 3 months ago

    No problem mate. There are a lot better ways of writing the code more efficiently, however it has worked fine in my garden sprinkler application for well over 18 months now. Cheaper than commercial offerings that's for certain! Happy learnings!

    0
    yoyosteven
    yoyosteven

    Answer 1 year ago

    Cuz there is no power to hold the switch , as the magnetic property will be not there

    0
    JawadT
    JawadT

    Question 5 months ago

    Hi,
    I want to ask about Blynk app.
    Can we use Blynk app in multiple android devices to control one node MCU?

    3
    kusantosh98
    kusantosh98

    Question 10 months ago

    how to delete all programe into nodemcu anyone help me

    0
    kusantosh98
    kusantosh98

    Question 10 months ago on Step 2

    hello sir anybody help me i will done all processes bt my 4 channel relay module is not working only one relay work all relay board light on off bt relay not on/off.

    0
    bill1959parker
    bill1959parker

    1 year ago

    Hi Thank you this is a very easy tutorial and the very first BLYNK tutorial I have managed to follow and it work. You put it in very simple steps I will definitely be following you keep up the good work. Thanks again.

    0
    dishaparkhi
    dishaparkhi

    Question 1 year ago on Introduction

    hi I am getting error on blynk app on mobile phone that "your device wasnt online"

    and also invalid library for rfid-master in arduino IDE

    0
    MazharS6
    MazharS6

    Question 1 year ago on Step 2

    Why not D0 pin?
    &
    Why I have to use 1 for OFF state & 0 for ON state?

    0
    yoyosteven
    yoyosteven

    Answer 1 year ago

    We can use D0 to

    0
    Zhuna87
    Zhuna87

    1 year ago

    Thank you. Very easy tutorial.

    0
    yoyosteven
    yoyosteven

    Reply 1 year ago

    Ur welcome, it means a lot to me

    0
    SourojitM
    SourojitM

    2 years ago

    Will it work as soon as the nodemcu is powered on
    Means will it automatically connect over the internet?

    0
    PiyushB5
    PiyushB5

    2 years ago

    i think relay should not work bcz relay is 5v and output of nodemcu is 3.3v...

    Let me know if i am wrong..

    0
    yoyosteven
    yoyosteven

    Reply 2 years ago

    It has a 5v out put , so it works for me

    0
    ErickFloorZ
    ErickFloorZ

    2 years ago

    hi why this is not work on relay 1 channel? but work normally on 4ch relay..can you have trik?

    0
    yoyosteven
    yoyosteven

    Reply 2 years ago

    Change the code