In the first post, we have seen how to set up ESP8266 NodeMCU and have also downloaded the app. Now in today’s post, we will discuss how to set up Blynk App and will also run this embedded project. You can also design this project with any Arduino board i.e. Arduino Nano along with ESP8266 chip but we have used NodeMCU.
Step 5: Setting Up the Blynk App:
To move on with the setup process,
- First, you need to install the Blynk app from the Google play store and get signed in.
- Now click the Create New Project and you will get a new screen.
- On the screen, enter the name of your project and then select the board as Node MCU.
- Now you will get the authentication token no. to your email. Finally, click on the create button.
- Now you will find your dashboard screen as below:
- On the dashboard, as shown above, just click on the topmost button ‘+’ to add widgets.
- In this project, we are going to add two bulbs and one fan speed controller.
- So as per the choice, we need to set up the digital pins for each of the appliances.
- It’s your choice of setting a push-type or button.
- Finally, label the button as ON and OFF in the settings as shown in the picture below:
y this, the settings of the Blynk app is done successfully.
Step6: Uploading the code for functioning:
- Open ARDUINO IDE
- Connect the Esp8266 wifi to your PC
- Now, click on the tool File-Examples-Blynk-Boards_Wifi-Esp8266Standalone.
- Finally select the correct board i.e, NodeMcu1.0 and also com port from the tools menu.
- You have to change the Baud Rate from:
Serial.begin(9600); to Serial.begin(115200)
- The important step is you need to enter your Wifi SSID and password in the double quotes as shown below.
- Now, save the file and click on the button upload.
Step 7: Schematic Diagram of the Project and Code:
#define BLYNK_PRINT Serial
char auth = “GdC7VOPVuwK7Rj6koOeiHR0xeMBnKGu8”; // the auth code that you got on your gmail
char ssid = “5 STAR”; // username or ssid of your WI-FI
char pass = “All in one”; // password of your Wi-Fi
// Debug console
pinMode(D1,OUTPUT); //extend these to D8 if you are using a 8 pin relay
digitalWrite(D1,HIGH); // Make it low if you want everything to go off
digitalWrite(D2,HIGH); // in case of a power cut
Blynk.begin(auth, ssid, pass);
Step 8: Explanation of the Code:
In this step we see how the code is executed and is explained clearly:
- Firstly, we have to include ESP8266 Wi-Fi library which helps in providing ESP8266 specific Wi-Fi routines and it means we are calling this function to connect to the network.
- By this BlynkSimpleEsp8266 library establishes the communication and interaction between Esp8266 and Blynk App.
- In the next step, Get and enter Auth Token which will be received from the Blynk App while creating a project.
- Now Get and enter the “ssid” and “password” that is your Wi-Fi and password.
- Now in the setup function put your setup or configuration code and it will only run once during the startup.
- In the setup function, it will initialize serial communication for debugging and logging with a baud rate of 9600.
- With this, the connection begins for respective Blynk Auth Token, Server Name, and Server Password.
- Finally, put your main code in void loop () function to run repeatedly. It helps in a continuous run with Blynk App commands…
Step 9: Working of the Project:
- The Home Automation is built around the ESP8266, Blynk Android App and a 4-channel relay board, etc. The hardware setup of the project must be as the circuit diagram.
- Initially, AC main appliances (Tube light, light and, fan) will be connected to the relays which are controlled by ESP8266.
- The user must install and configure the Blynk App as per the instructions given above to get the output.
- After setting up this, the user can click an icon in the app then automatically the information will be sent to ESP8266 via Wi-Fi.
- The ESP8266 analyses the received commands and works accordingly and turns ON/OFF of the device the user has been chosen.
- This is the working of the Project.
Practical Implementation–Home Automation using ESP8266 and Blynk App
Step 10: Output of the Project:
- After uploading the code, open the app on your smartphone.
- Connect it to your internet and now you would see your dashboard screen with three buttons.
- As initially the three buttons are given with the names: Bulb1, Bulb 2 and Fan Speed Controller.
- As per your requirement, you can switch on/off the required household appliance.
- By this, the project is done successfully.