Getting Started with NodeMCU ESP8266 and Blynk Basics
Getting Started with NodeMCU ESP8266 and Blynk Basics
Blynk is an app that lets you control NodeMCU ESP8266 through your phone easily. No need to write your own app. It supports both WiFi and mobile networks, available free on iOS and Android. This article walks through installation from scratch to uploading your first code.
Required Equipment
| Equipment | Quantity | Notes |
|---|---|---|
| NodeMCU ESP8266 V2 (CP2102) | 1 piece | Uses CP2102 chip for USB connection |
| Micro USB Type B to USB 2.0 Type A cable | 1 cable | 1 meter length |
| Power Adapter Micro USB 5V 2A | 1 unit | Powers the board |
| Breadboard MB-102 830 Point | 1 piece | For prototyping circuits |
| Jumper wire Male-Male 20cm | 40 wires | |
| Jumper wire Male-Female 20cm | 40 wires | |
| Jumper wire Female-Female 20cm | 40 wires | |
| Resistor 220 Ohm 1/4W | 10 pieces | Limits current for LED |
| LED 5mm Red | 5 pieces | |
| LED 5mm Green | 5 pieces |
Note: NodeMCU ESP8266 V2 board uses CP2102 USB-to-Serial chip. You must install the Driver before uploading code. Download the driver from Silicon Labs website.
Step 1: Install ESP8266 Board Package in Arduino IDE
Before using Arduino IDE with NodeMCU, you need to add the ESP8266 Board Package.
- Open Arduino IDE
- Go to File > Preferences
- In the Additional Boards Manager URLs field, paste this URL:
http://arduino.esp8266.com/stable/package_esp8266com_index.json - Click OK
- Go to Tools > Board > Boards Manager
- Type esp8266 in the search box
- Select esp8266 by ESP8266 Community and click Install
- Wait for installation to complete (about 2-3 minutes)
Step 2: Install Blynk Library
- Open Arduino IDE
- Go to Sketch > Include Library > Manage Libraries
- Type blynk in the search box
- Click Install on the first Blynk Library
- Wait until you see INSTALLED
Step 3: Create a Project in Blynk App
Install Blynk App
- Open Play Store or App Store
- Search for blynk
- Download and install the app
Create Account and New Project
- Open Blynk app
- Select Create New Account
- Enter Email and Password, then click Sign Up
- After creating account, select New Project
- Enter project name in Project Name field
- Select board as ESP8266
- Select connection type as Wi-Fi
- Choose your preferred theme (dark or light)
- Click Create
- The system will notify that Auth Token was sent to your registered Email. Click OK
Important: Open the Email registered with Blynk to Copy the Auth Token. This token will be used in Arduino code. If you forget, you can view it in the project later.
Step 4: Write Code and Upload
Open Example from Blynk Library
- Go to File > Examples > Blynk > Boards_WiFi > NodeMCU
- The code will look like this:
#define BLYNK_TEMPLATE_ID " YOUR_TEMPLATE_ID "
#define BLYNK_DEVICE_NAME " YOUR_DEVICE_NAME "
#define BLYNK_AUTH_TOKEN " YOUR_AUTH_TOKEN "
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = " YOUR_WIFI_SSID ";
char pass[] = " YOUR_WIFI_PASSWORD ";
void setup()
{
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
}
void loop()
{
Blynk.run();
}
Modify the Code
Edit these values:
| Value to Edit | Meaning |
|---|---|
BLYNK_AUTH_TOKEN | Auth Token from copied Email |
YOUR_WIFI_SSID | WiFi name for the board to connect to |
YOUR_WIFI_PASSWORD | WiFi Password |
Note: The board will connect to the WiFi credentials you enter. If you change WiFi, you must edit the code again. You could write code to accept values from Serial or EEPROM, but for now, just enter values directly for simplicity.
Upload Code
- Insert Micro USB cable into NodeMCU board
- Go to Tools > Port and select the Port where the board is connected
- Go to Tools > Board and select NodeMCU 1.0 (ESP-12E Module)
- Click Upload button
- Wait for upload to complete (about 10-20 seconds)
[image: Screenshot showing Arduino IDE with Blynk code, correct Board and Port selected]
Step 5: Verify via Serial Monitor
- Go to Tools > Serial Monitor or press Ctrl+Shift+M
- Set Baud Rate to 115200
- If everything is correct, you will see messages showing WiFi and Blynk Server connection status
- On Blynk app on your phone, you will receive a notification that the device connected successfully
[image: Screenshot showing Serial Monitor displaying successful connection message with IP address]
Things to check if connection fails:
- WiFi name and password are correct?
- Auth Token matches what is in the Blynk app?
- Board is connected to the correct Port?
- WiFi is 2.4GHz? (ESP8266 doesn’t support 5GHz)
อยากทำโปรเจคแบบนี้?
รับทำโปรเจค Arduino / IoT จบงานไว ส่งงานครบ พร้อมสอน
If you need Arduino project service or urgent IoT development, see full service details on the home page
จ้างทำโปรเจคเลย