Skip to content
Tutorial
13 min read
October 17, 2026

Getting Started with Blynk 2.0 on ESP32: Account, Template, Auth Token and First Connection

A step-by-step Blynk 2.0 setup for the ESP32: create the account and template, add datastreams, get your auth token, install the library, upload the sketch and control an LED from a dashboard.

What You'll Build

By the end of this guide your ESP32 will be connected to Blynk and showing as Online in Blynk.Console. You will be able to:

  • switch an LED on and off from a web dashboard (and, optionally, from the Blynk phone app), and
  • watch a gauge that shows how long the board has been running.

It is the smallest complete Blynk project, and it covers every piece of setup you will reuse in later projects: the account, the template, the datastreams, the auth token, the library and the sketch.

If words like template, datastream or virtual pin are new to you, read What Is Blynk 2.0? first. It takes about nine minutes and makes everything below easier.

Image pending: Finished setup: ESP32 on a breadboard with an LED, next to the Blynk web dashboard showing the switch and the uptime gauge

Components

4 items
NameQtyLink
ESP32 development board (with USB cable)×1—
LED (any colour), optional if your board has an on-board LED on GPIO 2×1—
220 ohm resistor, optional (only with an external LED)×1—
Breadboard and jumper wires, optional×1—

You also need:

  • a 2.4 GHz Wi-Fi network (the ESP32 does not connect to 5 GHz),
  • Arduino IDE with ESP32 support installed, and
  • a free Blynk account.

Many ESP32 development boards have a small LED connected to GPIO 2, so you can run the whole tutorial without any extra parts. If yours does not, wire an external LED as described in the next section.

Wiring (Only If You Use an External LED)

ESP32LED circuit
GPIO 2220 ohm resistor, then the LED's long leg (anode)
GNDLED's short leg (cathode)

The resistor limits the current so the LED and the ESP32 pin are not damaged. If your board's on-board LED is already on GPIO 2, you can skip this wiring.

Image pending: Wiring diagram: ESP32 GPIO 2 to a 220 ohm resistor, then the LED anode; LED cathode to GND

💡 Tip

The on-board LED is not on the same pin on every ESP32 board. GPIO 2 is common but not universal. If the LED never lights, check your board's pinout and change LED_PIN in the sketch. Our [ESP32 pinout guide](/articles/esp32-pinout-complete-guide) lists which pins are safe to use as outputs.

Step 1: Create Your Blynk Account

Open Blynk.Console at blynk.cloud and sign up. You can create the account in the console or in the Blynk mobile app. The free plan is enough for this tutorial.

Blynk.Console is the web application where you will create the template and the device. Blynk occasionally rearranges its menus. If a label here differs slightly from what you see, look for the same word nearby.

Step 2: Switch On Developer Mode

You can only create and edit templates while Developer Mode is on.

  1. Click your profile (My Profile, top right corner).
  2. Turn the Developer Mode switch ON.

If you later use the phone app to build a mobile dashboard, you need to switch it on there as well.

Step 3: Create a Template

  1. Open Developer Zone. It opens the My Templates section.
  2. Click + New Template.
  3. Enter a name, for example SolderHub ESP32 Test.
  4. Choose ESP32 as the hardware and WiFi as the connection type.
  5. Click Done.

The template screen now shows a Template ID and a Firmware Configuration section. You will paste these into your sketch later. The template has tabs for Info, Datastreams, Metadata, Events and Web Dashboard.

The template name you type here must match the BLYNK_TEMPLATE_NAME in your sketch, so keep it simple and copy it exactly.

Image pending: Blynk.Console New Template dialog with the name, ESP32 hardware and WiFi connection selected

Step 4: Add Two Datastreams

Datastreams are the channels between your board and the dashboard. You need two.

Open the Datastreams tab, click Add Datastream and choose Virtual Pin. Fill in the fields, then click Create.

Datastream 1Datastream 2
NameLED SwitchUptime
Virtual PinV0V1
Data TypeIntegerInteger
Min / Max0 / 10 / 604800
  • V0 carries the on/off value from the dashboard to the board.
  • V1 carries the uptime in seconds from the board to the dashboard.

You can leave the other settings at their defaults.

Step 5: Build the Web Dashboard

  1. In the template, open the Web Dashboard tab and click Edit.
  2. Drag a Switch widget from the Widget Box into the dashboard preview.
  3. Drag a Gauge widget in as well.
  4. Hover over the Switch, click its gear icon and choose the LED Switch (V0) datastream.
  5. Do the same for the Gauge and choose Uptime (V1).
  6. Save the template.

The dashboard layout belongs to the template, so every device you create from it gets the same dashboard.

Image pending: Web Dashboard tab in edit mode with a Switch linked to V0 and a Gauge linked to V1

Step 6: Create the Device and Get the Auth Token

  1. In Blynk.Console go to Devices and click Create New Device.
  2. Choose From template and select the template you just made.
  3. Give the device a name, for example ESP32 Test, and create it.

A notification shows your Template ID and Auth Token. They also stay available later under Devices → your device → Developer Tools. Copy both, because the sketch needs them.

⚠️ Warning

The auth token works like a password for this device. Never paste your real token or Wi-Fi password into a screenshot, a forum post or a public GitHub repository.

Step 7: Install the Blynk Library and the ESP32 Board Package

Blynk library

  1. In Arduino IDE open Sketch → Include Library → Manage Libraries.
  2. Search for Blynk.
  3. Select the latest version and click Install.

ESP32 board package

If you have never programmed an ESP32 in Arduino IDE, open Tools → Board → Boards Manager, search for esp32 and install the package published by Espressif Systems. Then select ESP32 Dev Module (or the closest match for your board) under Tools → Board, and pick the correct port under Tools → Port.

If you hit compile or connection problems, update both the Blynk library and the ESP32 package to their latest versions first. Some users report problems with certain library and ESP32 core combinations. If you are still stuck, try a different ESP32 core version.

Step 8: Upload the Sketch

Replace the three placeholders at the top with your own Template ID, template name, auth token and Wi-Fi details, then upload.

How the Sketch Works

  • #define BLYNK_TEMPLATE_ID, BLYNK_TEMPLATE_NAME and BLYNK_AUTH_TOKEN tell Blynk which template and which device this board is. They must appear before the Blynk #include.
  • BLYNK_PRINT Serial sends Blynk's connection messages to the Serial Monitor, which is how you see what is happening.
  • Blynk.begin() connects to your Wi-Fi network and then to Blynk.Cloud.
  • BLYNK_WRITE(V0) is a handler that runs automatically whenever the dashboard changes the value on virtual pin V0. param.asInt() reads the new value.
  • BLYNK_CONNECTED() runs when the board connects. Blynk.syncVirtual(V0) asks the cloud for the last switch value, so the LED matches the dashboard after a restart.
  • Blynk.virtualWrite(V1, value) sends a value from the board to the dashboard.
  • BlynkTimer calls sendUptime() every 10 seconds. Blynk's documentation warns against calling Blynk.* functions directly inside loop() and against long delay() calls, because both can get the device disconnected.

💡 Tip

Sending a value every 10 seconds is fine for testing. The free plan includes 100,000 messages per month, so for a board that stays on all month, raise SEND_INTERVAL_MS to 30000 or more, and check how Blynk counts messages.

Step 9: Watch the First Connection

  1. Open Tools → Serial Monitor and set the speed to 115200 baud.
  2. Press the EN (reset) button on the ESP32 if the output has already scrolled by.

You should see the Blynk version, then your IP address, then a connecting message, and finally a line starting with Ready (ping: ... ms). That line means the board is connected to Blynk.Cloud.

Now open Blynk.Console and look at your device. Its status should read Online.

Image pending: Serial Monitor at 115200 baud showing the Blynk version, the IP address and the Ready (ping) line

Step 10: Test the Switch and the Gauge

  1. In Blynk.Console open Devices → your device → Dashboard.
  2. Click the Switch. The LED on GPIO 2 should light up, and the Serial Monitor prints V0 changed, LED = 1.
  3. Click it again to switch the LED off.
  4. Wait up to 10 seconds and the Uptime gauge updates with the number of seconds the board has been running.

Congratulations, your ESP32 is now controlled from the cloud.

Image pending: Working result: dashboard switch turned on, LED lit on the breadboard and the uptime gauge showing a value

Optional: Add the Phone App

The web dashboard and the mobile dashboard are separate, so the phone app needs its own layout.

  1. Install the Blynk app on your iPhone or Android phone and log in with the same account.
  2. Switch on Developer Mode in the app.
  3. Find your template in the app, tap it and add a Switch and a Gauge linked to V0 and V1, the same way as on the web.

After that, your phone controls the same board through the same datastreams.

Using an ESP8266 (NodeMCU) Instead

The same project works on an ESP8266 board such as the NodeMCU. The template, datastreams, dashboard and device are exactly the same. Only a few things change in the Arduino IDE and in the sketch.

ESP32ESP8266 (NodeMCU)
Board packageesp32 by Espressif Systemsesp8266 by ESP8266 Community
Board to selectESP32 Dev ModuleNodeMCU 1.0 (ESP-12E Module)
Wi-Fi headerWiFi.hESP8266WiFi.h
Blynk headerBlynkSimpleEsp32.hBlynkSimpleEsp8266.h
On-board LEDGPIO 2 on most boardsGPIO 2 (D4), active low

The important difference is that the NodeMCU's on-board LED is active low: writing LOW turns it on and HIGH turns it off. The sketch below inverts the value for you.

If you have not used an ESP8266 in Arduino IDE before, you also need to add the ESP8266 board manager URL under File → Preferences before the package appears in the Boards Manager.

Troubleshooting

ProblemWhat to check
Device stays OfflineMake sure the Wi-Fi name and password are correct, the network is 2.4 GHz, and the signal is strong enough.
Never reaches "Ready"Confirm the Template ID, template name and auth token match your device exactly, with no extra spaces or quotes.
Compile errorsUpdate the Blynk library and the ESP32 board package, and make sure the three #define lines come before the #include.
Worked before, now offlineAfter updating the library or the ESP32 core, re-flash the board and run the Device Reprovision process in Blynk.Console.
Switch does nothingCheck that the Switch is linked to V0 and the sketch uses BLYNK_WRITE(V0). Check the LED pin and wiring too.
Random disconnectsRemove long delay() calls and any Blynk.* calls placed directly in loop(). Do not send more than a few values per second.
Dashboard shows nothing in the phone appThe mobile dashboard is separate from the web dashboard, so add the widgets in the app too.

Steps

  1. 1Create a Blynk account and switch on Developer Mode
  2. 2Create a template for ESP32 over WiFi and note the Template ID
  3. 3Add two datastreams: LED Switch on V0 and Uptime on V1
  4. 4Build the web dashboard with a Switch (V0) and a Gauge (V1), then save
  5. 5Create a device from the template and copy the Auth Token
  6. 6Install the Blynk library and the ESP32 board package in Arduino IDE
  7. 7Fill in the Template ID, name, auth token and Wi-Fi details, then upload the sketch
  8. 8Open the Serial Monitor at 115200 baud and wait for the Ready line
  9. 9Check the device shows Online, then toggle the switch and watch the LED and gauge

Make It Your Own

Once the switch and the gauge work, the same pattern covers almost any project:

  • Replace the uptime with a real sensor. Read your sensor inside a timer function, such as a DHT11 for temperature, and send the value with Blynk.virtualWrite(). Create a matching datastream in the template first, with the right data type and range, for example a Double for temperature.
  • Control something bigger than an LED. Connect a relay module input to the same GPIO and the switch on your dashboard now controls a real load. Many relay modules are active low, so check yours and invert the value in BLYNK_WRITE() if needed.
  • Add alerts. Blynk events can notify you when a value crosses a limit. The free plan includes 5 events, and a device can log at most 100 events per day.
  • Stop hardcoding Wi-Fi details. Blynk provides provisioning examples that let you enter Wi-Fi credentials through the app instead of writing them into the sketch. See the "Prepare Your Code" page in Blynk's documentation for the ESP example.
  • Keep the timer pattern. Whatever you add, schedule it with BlynkTimer and keep loop() free of delay() and direct Blynk.* calls.

Frequently Asked Questions

Why does my Blynk device stay offline? The usual causes are a wrong Wi-Fi name or password, a 5 GHz network, a weak signal, or an outdated Blynk library or ESP32 core. Fix those first, then check that the Template ID, template name and auth token in the sketch match your device exactly.

What should I check if the template or token does not match? Copy the Template ID and auth token again from Developer Tools on your device page, and make sure BLYNK_TEMPLATE_NAME is the exact name of the template. Leave no extra spaces or quotes. If you created a new device, the old token no longer applies.

The device worked yesterday and is offline today. What changed? If you updated the Blynk library or the ESP32 board package, re-flash the board and run the Device Reprovision process in Blynk.Console, as Blynk's troubleshooting guide suggests.

Do I have to put my Wi-Fi password in the sketch? Not necessarily. This guide does it to keep the first project simple. Blynk also offers provisioning, where credentials are entered through the app and stored on the board.

Can I use an ESP8266 or NodeMCU? Yes. See the ESP8266 section above for the board package, the headers and the active-low LED difference.

Can I use Blynk without a phone? Yes. The web dashboard in Blynk.Console works in any browser. The phone app is optional.

Is this free? Yes, the free plan covers this project. It allows 5 devices and 100,000 messages per month. Read What Is Blynk 2.0? for the full list of limits.

What's Next

You now have a working Blynk setup, and you can reuse it for any project: add more datastreams, drop more widgets on the dashboard, and read real sensors instead of uptime. If you want to compare it with a self-hosted approach, our ESP32 MQTT tutorial shows the same idea with your own broker.

For the concepts behind each step, see What Is Blynk 2.0?.

Signal In

Built from what makers search for

The lookups piling up in SolderHub's search bar every day shape what we publish next — new component pages, board guides, and firmware notes, sent out as they go live.

By subscribing you agree to our Privacy Policy. Unsubscribe anytime.