DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
Bettesworth Construction
Arduino

Smart Home Using NodeMCU ESP8266 and Blynk: A Safer, Updated Guide to the 2021 IoT Project

The 2021 NodeMCU ESP8266 and Blynk project combines four relay channels, Blynk mobile and web control, and local switches. This updated guide explains the original pinout, current Blynk workflow, provisioning, testing, limitations and mains safety.

By Bettesworth Construction Team 8 min read
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The 2021 NodeMCU ESP8266 and Blynk project builds a four-channel Wi-Fi relay controller. It can operate four loads from Blynk’s mobile app or web dashboard while retaining local push-button or wall-switch control. The design is useful for a low-voltage electronics prototype, but an exposed hobby relay board is not a certified household installation. Test the controller at low voltage; use a qualified electrician for permanent mains wiring.

The original project was published on Hackster.io on June 28, 2021. “Blynk 2.0” refers to the then-new Blynk IoT workflow. Current Blynk documentation uses templates, datastreams, dashboards, Developer Mode and dynamic provisioning, so some original screens and library references are historical.

As an Amazon Associate I earn from qualifying purchases.

What the project does

The system has four independent relay channels:

Blynk mobile app / web dashboard
             |
         Blynk Cloud
             |
       Wi-Fi router / Internet
             |
       NodeMCU ESP8266
          |          |
   Relay outputs   Local switches
          |
  Four-channel relay module
          |
       Connected loads

Each relay can switch one appliance or circuit, subject to the relay module’s ratings and the installation requirements. The ESP8266 provides Wi-Fi connectivity, Blynk provides the cloud interface, and physical switches provide local control.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The project’s “feedback” is controller-state feedback: the ESP8266 reports the relay command state to Blynk. It does not prove that a relay contact moved, that power reached the appliance, or that the appliance is operating. Current or voltage sensing would be required for genuine electrical-load monitoring.

#1 Best Overall
OSOYOO IoT WiFi Learning Coding Starter Kit with ESP8266 Module for Arduino
  • Innovation, keep pace with the times :Add Build on the power of Blynk to configure smart home automation and build exciting IoT project.
  • Programmable learner kit for beginners and professionals: Perfect intro to programmable electronic and IoT robotics .
  • Wifi programming and control: With ESP8266 WIFI Shield , you can remote control programming and the sensors.Learn the basics behind the Internet of Things, build your own connected devices .
  • Creative IoT Projects:This kit Includes Everything You Need To Build and Engineer Your Own smart home: WiFi Shield, Basic Board for Arduino, PIR motion sensor, Ultrasonic Sensor , Servo Motor, sound sensor, Obstacle Sensors, Buzzer Sensor Module, Photoresistor, Temperature/Humidity sensor, BMP180,Water detection sensor ,gas Sensor ,relay,Resistors package.
  • Simple ,intelligent: Control your IOT System by Android and iOS App,Sample code are straight forward. free IoT service on OSOYOO website .

Parts and tools

Low-voltage prototype

  • One NodeMCU ESP8266 development board
  • One four-channel 5 V SPDT relay module
  • Four push buttons or switches
  • A regulated 5 V DC supply
  • Connecting wires and terminal connectors
  • USB cable, computer and Arduino IDE
  • Optional custom PCB

The original tutorial reports using a 5 V, 2 A mobile charger. That is a project-specific choice, not a universal specification. Size the supply for the ESP8266 and the relay coils, including startup margin, and investigate brownouts if the board resets when several relays energize.

Optional custom PCB components

The original PCB list includes four 5 V relays, four BC547 transistors, four PC817 optocouplers, four 510 Ω resistors, five 1 kΩ resistors, five LEDs, five 1N4007 diodes, four push buttons and terminal connectors. A bare relay requires suitable transistor drive and flyback protection; a ready-made module may already include these parts.

GPIO assignments used by the original design

Function NodeMCU label Important caution
Relay 1 D1 Board label, not the raw GPIO number
Relay 2 D2 Board label, not the raw GPIO number
Relay 3 D5 Board label, not the raw GPIO number
Relay 4 D6 Board label, not the raw GPIO number
Manual switch 1 SD3 Check the exact board and boot behavior
Manual switch 2 D3 GPIO0; must not be held LOW during boot
Manual switch 3 D7 May have board-specific peripheral constraints
Manual switch 4 RX Shares the serial receive function

NodeMCU labels such as D1 and D3 are aliases mapped by the board definition. Do not replace them casually with GPIO numbers or copy this table to a different ESP8266 board without checking its schematic.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The original switch inputs use INPUT_PULLUP. Wire each switch between its input pin and ground: open normally reads HIGH, while a pressed or closed switch reads LOW. D3/GPIO0 is a boot-strapping pin. The ESP8266 documentation identifies GPIO0, GPIO2 and GPIO15 as part of boot-mode selection; a switch or relay circuit that forces an unsuitable level can prevent startup. RX can also interfere with serial diagnostics or startup if external circuitry drives it.

Rank #2
DIYables Basic Electronics Starter Kit for Arduino, ESP32, ESP8266, Raspberry Pi – Sensor and Component Kit for Beginners and DIY Projects (Boards Not Included)
  • COMPLETE STARTER KIT FOR BEGINNERS: Includes a variety of 10 essential sensors and electronic components—perfect for learning, experimenting, and building creative projects with Arduino, ESP32, ESP8266, and Raspberry Pi.
  • WIDE RANGE OF COMPONENTS: Covers multiple sensor types such as temperature, motion, and light detection, helping you create interactive circuits and smart devices for home, school, or STEM learning projects.
  • EASY INTEGRATION WITH MICROCONTROLLERS: Designed for seamless use with official Arduino boards and other popular platforms—making prototyping simple for beginners and experienced makers alike.
  • BOARDS NOT INCLUDED: This kit includes only sensors and components; compatible Arduino, ESP32, ESP8266, or Raspberry Pi boards must be purchased separately.
  • TUTORIALS AVAILABLE FOR QUICK START: Step-by-step tutorials for Arduino, ESP32, and ESP8266 are provided—search for "DIYables Basic Electronics Starter Kit" to access detailed guides and example projects.

Where possible, choose less sensitive GPIOs after checking boot levels, flash connections, serial use and the specific NodeMCU variant. If you retain the original assignments, test with switches disconnected and reconnect them one at a time.

Relay module and power considerations

The ESP8266 uses 3.3 V logic, while the relay coils in this design are 5 V. A relay module’s input threshold determines whether a 3.3 V ESP8266 signal reliably activates it. Modules vary: some are active-low, some active-high, and some include transistor drivers, LEDs, flyback diodes or optocouplers.

Do not assume that a board marked “opto-isolated” provides complete galvanic isolation. Check whether the logic and relay supplies share ground, whether a JD-VCC link is fitted, and how the input circuit is constructed. Follow the module’s documentation and verify operation with a meter before connecting a load.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Define the relay’s active logic in firmware, initialize every output to a known safe state, and test power-up behavior. A relay can switch on briefly during reset if the GPIO state and module input logic are not controlled.

Rank #3
KEYESTUDIO IOT ESP32 Smart Home Starter Kit for Arduino and Python,Electronics Home Automation Coding Kit, Wooden House DIY Sensor Kit,STEM Educational Set for Adults Teens 15+
  • Complete Project-Based Learning Path – Build 13 progressive projects (LED blink → button control → PIR motion sensor → music playback → motorized doors/windows → SK6812 RGB lighting → fan control → LCD display → gas alarm → temperature/humidity monitor → RFID door unlock → Morse code access → WiFi control → mobile APP remote control). Each project builds on the previous one, ensuring you understand both the electronics and the programming logic behind every smart home feature.
  • Master Two Industry-Standard Languages – Learn to code in both Arduino C++ and MicroPython with 13 detailed tutorials for each language. Compare how the same hardware behaves under different programming approaches – a valuable skill for any aspiring engineer. Perfect for classrooms teaching multiple coding languages or self-learners who want flexibility.
  • Build a Real WiFi-Controlled Smart Home – Assemble the wooden house structure and integrate sensors to create a functioning smart home system. Control lights, fans, door servos, and RGB lighting directly from your mobile APP (iOS/Android) . Experience how IoT works in real life – from manual control to automated responses based on temperature, humidity, motion, and gas detection.
  • Comprehensive Online Wiki with No Guesswork – Our detailed online tutorials (also accessible via the packaging) include wiring diagrams, full code explanations, and step-by-step assembly guides for every project. Whether you're a complete beginner or a teacher preparing lessons, the structured content eliminates confusion and helps you succeed from project 1.
  • Everything You Need to Get Started – (TIPS: Batteries are NOT Included)This kit includes the ESP32 development board, expansion board, wooden house parts, all sensors and modules (DHT11, PIR motion, gas sensor, RFID, SK6812 RGB, servo motors, fan, LCD1602, etc.), and connection cables. NOTE: 6x AA batteries are required (NOT Included). The kit is unassembled – you'll build it yourself following our online tutorials, making the learning experience truly hands-on.

Set up Blynk using current terminology

  1. Create an account through Blynk Cloud and enable Developer Mode if prompted.
  2. Create a device template for ESP8266 hardware with Wi-Fi connectivity. Blynk describes a template as the shared configuration for hardware settings, datastreams and dashboards; see the device-template documentation.
  3. Create four integer virtual-pin datastreams: V1, V2, V3 and V4. Use 0 for OFF and 1 for ON. The datastream guide explains the current configuration.
  4. Add four switch controls to the web dashboard and four button controls to the mobile dashboard.
  5. Map each control to its matching datastream: V1 to relay 1, V2 to relay 2, and so on.

Use the template and datastream names consistently. Changing a datastream definition after firmware deployment can cause existing devices to behave incorrectly unless the firmware and configuration are updated.

Arduino IDE and firmware

Install the Arduino IDE and the ESP8266 board package. Install the current Blynk library required by the generated template workflow and install AceButton if the sketch retains the original button-handling approach.

The 2021 source identifies Blynk library version 1.0.0-beta.3 and uses historical definitions such as:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#define BLYNK_TEMPLATE_ID ""
#define BLYNK_DEVICE_NAME ""

Do not treat that beta version or those names as the current universal installation recipe. Generate the firmware configuration from the current Blynk template flow and place the generated template identifiers before the library includes, as described in Blynk’s code-preparation guide.

Rank #4
Sale
Freenove Super Starter Kit for ESP8266 (Included), 32-bit 160 MHz Mini Microcontroller, Onboard Wi-Fi, Python C Code, 497-Page Detailed Tutorial, 173 Items, 77 Projects
  • ESP8266: Small but powerful, 32-bit microprocessor up to 160 MHz, 160 KB RAM, 4 MB flash, onboard 2.4 GHz Wi-Fi
  • 2 Sets of Codes: MicroPython and C, two popular programming languages
  • 497-Page Detailed Tutorial in Total: Provides step-by-step guide with basic electronics and components knowledge (The download link can be found on the product box) (No paper tutorial)
  • 77 Projects from Simple to Complex: Each project has schematics, wiring diagrams, complete code and detailed explanations
  • 173 Items in Total: Includes commonly used electronic components, modules, sensors, wires and other compatible items

The original firmware uses Blynk Edgent for Wi-Fi provisioning. Upload the first firmware over USB, power the board within Wi-Fi range, and provision it through the Blynk app. Store credentials securely and provide a physical reset or provisioning button. Blynk also recommends a status LED so provisioning and connection states can be diagnosed.

Test the system in stages

  1. USB only: Upload the firmware with external switches and relay wiring disconnected. Confirm the selected board and open the serial monitor.
  2. Provisioning: Add the device in Blynk, connect it to Wi-Fi and confirm its online status.
  3. One channel: Connect one relay input and test it with an LED or other isolated low-voltage load.
  4. Local control: Add one switch and confirm that pressing it changes both the relay and the matching Blynk datastream.
  5. Expand gradually: Add the remaining channels, watching for resets, chatter or a collapsing supply voltage.
  6. Only then consider mains: Use an enclosed, properly rated installation completed by a qualified person.

What happens when the network fails?

Remote Blynk control requires the device’s Wi-Fi connection, Internet access and Blynk Cloud availability. Local switches can continue to work without Wi-Fi only if the firmware handles them independently of Blynk connectivity. The behavior after a power failure, watchdog reset, firmware update or reconnection depends on the sketch: explicitly decide whether outputs default OFF or restore their previous state. For safety-critical loads, default-OFF behavior is generally the more cautious starting point.

“Control from anywhere” therefore means control from a location with Internet access while the configured device, account and cloud service are available. It is not local autonomous control.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting

The ESP8266 will not boot

Disconnect relay and switch wiring and upload with USB alone. Check D3/GPIO0 and the other boot-sensitive levels, inspect whether RX is being driven, verify the NodeMCU board selection, and confirm that the 5 V supply is stable. Reconnect one circuit at a time. The ESP8266 Arduino documentation covers the relevant boot behavior.

Best Value
Sale
LAFVIN AIoT Starter Kit, ESP32-S3 AI Voice Control Electronics Starter Kit, DHT11 Temperature Humidity Sensor, Servo, Relay for Smart Home & IoT DIY Projects
  • 【High-Performance ESP32-S3 Microcontroller】 Equipped with revolutionary MCP protocol technology, the kit delivers a native AI voice control experience, perfectly adapting to various AIoT application scenarios, suitable for beginners, educators and makers.
  • 【8 Versatile Hardware Modules Included】Comes with RGB LED module (full-color dimming, breathing light effect), WS2812 smart light strip (8 programmable LEDs), DHT11 sensor (real-time temperature and humidity monitoring), SG90 servo, DC fan, dual relay, raindrop and soil sensor, meeting diverse project needs.
  • 【Zero-Threshold AIoT Control】Adopts innovative MCP protocol, allowing AI models to directly recognize hardware functions without complex programming. Pre-compiled firmware supports plug-and-play after burning, with an extensible architecture for secondary development.
  • 【Multi-Scenario Application Coverage】Widely applicable to STEM education (learning IoT, AI interaction, embedded programming), smart home prototype verification, maker project development, and smart agriculture (soil monitoring, automatic irrigation systems).
  • 【Comprehensive Learning & Technical Support】Provides an online document center with detailed quick-start guides and free professional technical support to answer questions and assist in problem-solving, helping users get started quickly.

The relay works backwards

The module may be active-low. Confirm its input logic, invert the firmware mapping if necessary, and initialize outputs to a defined safe state. Check that the Blynk widgets send 0 and 1 as intended.

The switch works but the dashboard is wrong

When local firmware changes a relay, it must also publish the new state to the matching virtual datastream. Check V1–V4 mapping, stale sessions on other phones and any changed datastream definitions.

Provisioning fails

Use the physical reset/provisioning control, keep the board powered throughout setup, move it closer to the access point, and confirm the app is using the intended device. If stored credentials are corrupted, reflash over USB and add serial logging during development.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Relays chatter or the board resets

Check the 5 V supply, wiring, common-ground arrangement and coil current. Separate noisy relay wiring from logic wiring, use the module’s flyback protection, and test channels individually.

Mains safety: do not skip this section

Do not prototype 110/120 V or 220/230 V wiring on a breadboard, on an open desk, or in an enclosure that leaves terminals accessible. Disconnect all power before changing wiring. Mains work can cause fatal shock, arc flash and fire.

  • Use relays, fuses, conductors, terminals and enclosures rated for the local voltage and the actual load.
  • Consider motor, transformer, compressor, LED-driver and other inrush or inductive loads; steady-state wattage alone is not enough.
  • Maintain physical separation and suitable creepage and clearance between mains conductors and SELV/logic wiring.
  • Provide strain relief, secure terminal covers and a flame-suitable enclosure.
  • Do not assume a low-cost relay module is code-compliant or suitable for unattended household control.
  • Have permanent household wiring designed or installed by a qualified electrician in accordance with local requirements.

The original project includes a high-voltage connection, but its warning is not a substitute for an electrical installation assessment. For a fixed home installation, a certified enclosed smart switch is usually a safer and more supportable choice than an exposed hobby board.

Limitations and alternatives

ESP8266 remains inexpensive and adequate for four relays, with mature Arduino support, but it is an older 2.4 GHz platform with limited resources and awkward boot-sensitive GPIOs. This design also has no native modern smart-home standard support and depends on Blynk’s cloud service for remote control.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Blynk: Fastest route to mobile and browser dashboards, but dependent on an account, app, cloud service and current plan limits.
  • Home Assistant with MQTT or ESPHome: Better for local-first control and a larger multi-device installation, but requires more setup and normally an always-on host.
  • ESPHome or Tasmota: Stronger local and MQTT-oriented options, though they are not drop-in replacements for the original Blynk sketch.
  • Certified commercial switches: Better enclosure, certification and installation documentation; less customizable and usually less educational.

Maintenance checklist

  • Record the board model, GPIO mapping, relay active logic and safe boot state.
  • Keep firmware and library versions documented.
  • Never publish Blynk tokens, passwords or Wi-Fi credentials.
  • Use a unique Blynk password and consider a separate IoT Wi-Fi network.
  • Test local fallback control periodically.
  • Inspect terminals, enclosure, heat and cable strain relief.
  • Back up the working firmware and Blynk template configuration.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Site Office

Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.