In this internet of things tutorial, I have explained how to make NodeMCU projects using Blynk and Google Assistant to control relays with voice commands and manual switches. You can also control the appliances from the Blynk IoT App and Blynk cloud web dashboard.
I have used the FREE plan of all the IoT Applications for this NodeMCU home automation project using Blynk IoT.
So if you follow all the steps, you can easily make this IoT project with NodeMCU and Blynk app.
Circuit of the Blynk NodeMCU Projects
The circuit is very simple, I have used D6 and D7 GPIO pins to control the 2-channel relay module.
And the GPIO D1 & D2 connected with the pushbuttons to control the relay module manually.
I have used the INPUT_PULLUP function in Arduino IDE instead of using the pull-up resistors with each switch.
As per the source code, when the control pins of the relay module receive the LOW signal the respective relay will turn on and the relay will turn off for the HIGH signal in the control pin.
I have used a 5V 2Amp power supply to supply the NodeMCU and relay module.
Required Components for the NodeMCU projects
- ESP8266 NodeMCU
- 2-channel 5V SPDT Relay Module
Tutorial video on Blynk ESP8266 Home Automation
In this Blynk tutorial video, I have covered the following steps in detail.
- Clone old template for Blynk IoT Project.
- Add NodeMCU in the Blynk IoT App, set up Mobile Dashboard.
- Code for the NodeMCU Project.
- Connect IFTTT with Blynk to control relay with Google Assistant
- Syntax for the Blynk Webhooks URL in IFTTT to update Datastreams values.
Blynk IoT Cloud setup
For this project, you have to create 2 Datastreams using V1 and V2 virtual pins to control 2 relays.
Please refer to the following article for the Blynk IoT Cloud account setup.
Program NodeMCU with Arduino IDE
In the Tutorial video, I have explained all the steps to program the NodeMCU using Arduino IDE.
- Update the Preferences –> Aditional boards Manager URLs: https://dl.espressif.com/dl/package_esp32_index.json, http://arduino.esp8266.com/stable/package_esp8266com_index.json
- Then install the ESP8266 board from the Board manager or Click Here to download the ESP8266 board.
- Install all the required libraries in Arduino IDE:
- Install the Blynk library from Include Library or Click Here to download.
Go to Sketch -> Include Libraries -> Manage Libraries in Arduino IDE.
When you try to install the Blynk library, it may ask you to install all the dependencies. Then Click on Install All.
Code for Blynk IoT Cloud ESP8266 home automation
After downloading the code, you will get 10 files. ( 1 .ino & 9 .h files). You have to keep all these files in the same folder.
Then open the .ino file in Arduino IDE, select the NodeMCU 1.0 board then compile the code. If you have downloaded all the required libraries then you should not get any errors.
In code, you have to update only the BLYNK_TEMPLATE_ID & BLYNK_DEVICE_NAME as shown in the video. You don’t have to enter the W-Fi credentials in the code.
Now upload the code to NodeMCU.
In the tutorial video, I have explained, how to update Wi-Fi credentials from the Blynk IoT app.
Connect Blynk with Google Assistant using IFTTT
In the following article, I have explained all the steps to connect Blynk with Google Assistant using the FREE IFTTT account.
URL syntax to send web requests in New Blynk IoT platform
Following are the server addresses for different regions. The server region could be found in the right bottom corner of the web interface in the Blynk account.
- fra1.blynk.cloud – Frankfurt
- lon1.blynk.cloud – London
- ny3.blynk.cloud – New York
- sgp1.blynk.cloud – Singapore
- blr1.blynk.cloud – Bangalore
I have used the following Blynk URLs to send web requests from IFTTT to update the Datastreams values in the Blynk server.
NodeMCU ESP8266 control Relays with Blynk App
If the NodeMCU is connected with the Wi-Fi, then you can control the relays from anywhere in the world using the Blynk App. You can also monitor the real-time feedback.
Control relays manually with Push Buttons
You can also manually control the appliances from the pushbuttons. If the NodeMCU is connected to the internet then it will send real-time feedback to the Blynk Cloud.
Control Relays with Google Assistant
To control the relays with Google Assistant, just say the pre-defined voice commands. The Google Assistant will trigger the related IFTTT applet to send the related web request to the Blynk server.
I hope you like this IoT project idea with the new Blynk 2.0 IoT Cloud and NodeMCU ESP8266.
Click Here for more such ESP8266 projects.
Please do share your feedback on this IoT project. Thank you for your time.