Home Automation with 8-Channel Relay Output
To get started we need to download the Arduino IDE and some necessary drivers.
The Arduino IDE can be downloaded via this link – www.arduino.cc
After downloading the Arduino IDE navigate to File => Preferences and in the additional boards URLs add the below URL
After that navigate to the Tools>Boards>Board Manager and scroll down the list until you do not find ESP8266 click on it and then hit install. Now you have setup the Arduino IDE to work along with the node MCU.
Additionally you need to install the drivers if you are on a windows based computer. The drivers can be downloaded and install from the below link.
Once the driver is installed, it is time to program the NodeMCU, for this select the NodeMCU 1.0 board from the Tools => Boards menu of the Arduino IDE.
Now need to find the specific port to which the NodeMCU is connected to the computer. This can be found in device manager. In Tools => Ports, make sure you select the right port
Getting Started with Blynk
IN ORDER TO USE BLYNK APP YOU WOULD NEED:
- Hardware that works with Blynk.
- If your hardware does not have connectivity on board, you can use shields like Ethernet, WI-Fi, GPRS and many others. Blynk also works over Bluetooth and USB
- DOWNLOAD BLYNK APP FOR ANDROID OR IOS
2. GET THE AUTH TOKEN
In order to connect Blynk App and your hardware, you need an Auth Token.
- Create a new account in Blynk App.
- Create a New Project. Then choose the board and connection you will use.
- After the project was created, we will send you Auth Token over email.
- Check your email inbox and find the Auth. Token.
- INSTALL BLYNK LIBRARY
☝️ Blynk library should be installed manually. Follow the instructions:
- Download the latest release .zip file.
- Unzip it. You will notice that archive contains several folders and several libraries.
- Copy all these libraries to your_sketchbook_folder of Arduino IDE. To find the location of your_sketchbook_folder, go to top menu in Arduino IDE: File -> Preferences (if you are using Mac OS – go to Arduino → Preferences)
The structure of your your_sketchbook_folder should now look like this, along with your other sketches (if you have them):
☝️ Note that libraries should go to libraries and tools to tools. If you don’t have tools folder you can create it by yourself.
3. CREATE YOUR FIRST EXAMPLE SKETCH CODE
Blynk works with hundreds of hardware models and connection types. We prepared Blynk Examples Sketch Builder that allows you to create example code for your hardware.
- Choose Your board (for example: Arduino UNO, NodeMCU)
- Choose your connection (WiFi, Ethernet, Bluetooth, USB…)
4. PASTE THE AUTH TOKEN
- In the example sketch, find this line:
char auth = “YourAuthToken”;
- Change it with your Auth Token (it should be in your email inbox after you created the Project in the Blynk app. Now it should exactly like this (☝️ don’t forget the ” “):
char auth = “53e4da8793764b6197fc44a673ce4e21”;
Steps to open the source code in Arduino IDE
paste the Character token here in above space
SSID: Name of your Wifi connection
(Can be Mobile Hotspot)
Password: Wifi password
In addition, after completing all the above-mentioned process upload the code in your NODEMCU
By selecting the right Board
After doing all the steps
add buttons to your project screen and assign them the pins as D1, D2; as per our requirment for the functioning of the relays