In the previous article, I shared how to get started with NodeMCU (ESP8266) and program it using Arduino IDE, Check it out here. In this tutorial, we will see how to control appliances from anywhere across the globe using Blynk. I will demonstrate NodeMCU LED control using Blynk app. The Blynk can be used for home automation and various other applications.
Here for demonstration, I have used LEDs, you can replace LEDs with Relays to use other high power appliances.
So lets get started…
1. Software Required:
2. Hardware Required:
First make the connection as shown in the picture above.
- Connect 1st LED to pin D0.
- Connect 2nd LED to pin D1.
- Use 220Ohm resistors each in series with the LED’s.
That’s all you have to do. Now move on to the next step.
Setting Up Blynk:
First install Blynk application on your device. Once you have installed the application Sign-in with Google account. Now follow the steps below :-
- Open “New Project”.
- Give a name to the project.
- Open “Choose Device”.
- Scroll down and select “NodeMCU” and hit “Create”
An authentication token will be sent to you via Gmail. Now press “OK”.
- Goto the add button on top right (+).
- Select button. (you will need two, to control both LEDs).
- Now you will see two buttons on the screen which you can touch and hold to drag around.
- Select button. this will open button settings.
- Give a name to the button. Here I have named it “LED 1”.
- Now select a pin. Here I have selected “D0” because one LED is attached to D0.
- Now toggle the Mode to “SWITCH”.
Do the same things with the Second button. Just give a different name and different pin. Here “D1”.
With that been done we can move on to the next step. uploading Code to NodeMCU.
In this step you will have to set up the Arduino IDE to program NodeMCU (ESP8266). I have already shared it in the previous tutorial. You can check out the video tutorial here.
Once the IDE is all setup you have to add the Blynk Libraries and Tools. For that follows the following steps:-
- Download and Extract this Zip file.
- Open the libraries folder and copy all the content.
- Open the folder where Arduino IDE is installed, Usually, it is in C drive by default in “Program Files folder.
- In the Arduino folder, open the libraries and paste all the content.
- Now goto tools folder in of the unzipped package and Copy all its content and Paste it in the “tools” folder in Arduino.
That will load all the Blynk tools and examples in the Arduino IDE. Now open the IDE:-
- Goto >> File >> Examples >> Blynk >> Boards_WiFi >> ESP8266_Standalone.
- Add the authentication token received in the mail to the “auth”.
- Add the name of your WiFi where SSID is asked.
- And add your WiFi password.
That’s all now connect your NodeMCU to the PC , Select the right com port, Select the right board type and upload the code.
Once everything is setup and NodeMCU is programmed you can move on to test the setup. First power up the board and make sure the WiFi is on. The Board will automatically get connected to the WiFi network.
Next open the blink app hit the play button on the top right corner. It will take a few seconds and the app will be connected to the blink server.
Now just hit the buttons to turn on/off the LEDs.
That is all for this tutorial. In the next tutorial, I will share more advanced home automation.
I hope this tutorial helps you get started. If you have any questions feel free to ask in the comments and I will try to answer it as soon as possible.