กลับหน้าหลัก
views
Getting Started with NodeMCU ESP8266 and Blynk Basics
Last updated on

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.

Photo showing NodeMCU ESP8266 V2 with Micro USB cable placed on Breadboard

Required Equipment

EquipmentQuantityNotes
NodeMCU ESP8266 V2 (CP2102)1 pieceUses CP2102 chip for USB connection
Micro USB Type B to USB 2.0 Type A cable1 cable1 meter length
Power Adapter Micro USB 5V 2A1 unitPowers the board
Breadboard MB-102 830 Point1 pieceFor prototyping circuits
Jumper wire Male-Male 20cm40 wires
Jumper wire Male-Female 20cm40 wires
Jumper wire Female-Female 20cm40 wires
Resistor 220 Ohm 1/4W10 piecesLimits current for LED
LED 5mm Red5 pieces
LED 5mm Green5 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.

  1. Open Arduino IDE
  2. Go to File > Preferences
  3. In the Additional Boards Manager URLs field, paste this URL:
    http://arduino.esp8266.com/stable/package_esp8266com_index.json
  4. Click OK
  5. Go to Tools > Board > Boards Manager
  6. Type esp8266 in the search box
  7. Select esp8266 by ESP8266 Community and click Install
  8. Wait for installation to complete (about 2-3 minutes)
Screenshot showing Boards Manager window in Arduino IDE with esp8266 search results

Step 2: Install Blynk Library

  1. Open Arduino IDE
  2. Go to Sketch > Include Library > Manage Libraries
  3. Type blynk in the search box
  4. Click Install on the first Blynk Library
  5. Wait until you see INSTALLED
Screenshot showing Manage Libraries window with blynk search results and Install button

Step 3: Create a Project in Blynk App

Install Blynk App

  1. Open Play Store or App Store
  2. Search for blynk
  3. Download and install the app

Create Account and New Project

  1. Open Blynk app
  2. Select Create New Account
  3. Enter Email and Password, then click Sign Up
  4. After creating account, select New Project
  5. Enter project name in Project Name field
  6. Select board as ESP8266
  7. Select connection type as Wi-Fi
  8. Choose your preferred theme (dark or light)
  9. Click Create
  10. 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

  1. Go to File > Examples > Blynk > Boards_WiFi > NodeMCU
  2. 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 EditMeaning
BLYNK_AUTH_TOKENAuth Token from copied Email
YOUR_WIFI_SSIDWiFi name for the board to connect to
YOUR_WIFI_PASSWORDWiFi 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

  1. Insert Micro USB cable into NodeMCU board
  2. Go to Tools > Port and select the Port where the board is connected
  3. Go to Tools > Board and select NodeMCU 1.0 (ESP-12E Module)
  4. Click Upload button
  5. 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

  1. Go to Tools > Serial Monitor or press Ctrl+Shift+M
  2. Set Baud Rate to 115200
  3. If everything is correct, you will see messages showing WiFi and Blynk Server connection status
  4. 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

จ้างทำโปรเจคเลย

Project estimate

Want something like this? Open the estimate page.

The long form is now on a separate estimate page, so this article stays clean.

ความคิดเห็น

รีวิวจากคนใช้งานจริง

รีวิวจากลูกค้าและคนที่เคยใช้งาน

ถ้าเคยสั่งงาน เคยอ่านหน้านี้แล้วได้ประโยชน์ หรือมีข้อเสนอแนะ ฝากรีวิวไว้ได้เลย

กำลังโหลดรีวิว...