---
description: >-
  In this activity we will be using the Blynk app to switch a light bulb on and
  off over the internet.
---

# A light bulb switch using NodeMCU and the Blynk app

### The outcome of this workshop/tutorial&#x20;

* Learn how to setup the circuit for the relay, light bulb and the nodeMCU.
* Learn how to use a relay module to switch a light bulb on and off.
* Learn to connect the relay module to the power supply.
* Learn to setup the Blynk app on your smartphone.
* Learn how to install the Blynk Library on the Arduino IDE.
* Learn how to configure the Blynk to connect to your local network.
* Learn how to configure Blynk code to communicate with your nodeMCU and Blynk app.



### What will you need?

* NodeMCU Dev Kit
* male-to-male & male-to-female jumper cables&#x20;
* A relay Module&#x20;
* A 220V light bulb
* globe holder&#x20;
* breadboard&#x20;
* 5 V power supply

### Setting up the circuit

![setup of the circuit to control a light bulb with a blynk app.](https://3073865318-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ly3RLHyAwTi7Hml5lZN%2F-M0s3deDcpSzLdqv1woM%2F-M0s45hC1K9E9gd8p008%2Fledrelay.png?alt=media\&token=dafaf1a9-4c20-46f4-b41e-4279b2580471)

1. Connect the positive terminal of the 5V power supply to the positive on the breadboard. Also connect the negative terminal on the negative of the breadboard.&#x20;
2. Connect the positive pin of the relay module to the positive on the breadboard. Then connect the negative pin of the relay module to the negative on the breadboard.
3. Connect the signal pin of the relay to pin D0 on the nodeMCU.
4. Connect the long leg of the LED to pin D0 of the nodeMCU. Then connect the short leg to the one terminal of the resistor and then connect the other side of the resistor to the&#x20;

```
#define BLYNK_PRINT Serial        
#include <ESP8266WiFi.h>        
#include <BlynkSimpleEsp8266.h>        
char auth[] = "authtocken"; // PASTE YOUR AUTHENTICATION CODE HERE        
// Your WiFi credentials.        
char ssid[] = "ssid"; //WIFI NAME        
char pass[] = "password"; //PASSWORD        
void setup()        
{        
 Serial.begin(9600);        
 Blynk.begin(auth, ssid, pass);        
}        
void loop()        
{        
 Blynk.run();        
}        
```
