Skip to main content

IoT Switch | Blynk (ESP 32)

 


IoT Switch | Blynk (ESP 32)

This project is used to turn on/off the leds or home appliances through internet from any part of the world.  
FOR VIDEO :   

THINGS NEEDED

  1. ESP 32
  2. 1K Resistor
  3. LED'S
  4. BreadBoard
  5. Jumper Wire's

CIRCUIT DIAGRAM

WIRING

LED'S TO ESP32

  • Connect the LED which you want to adjust the brightness to D2 (GPIO 2) of ESP32.
  • Connect LED 1 to D5 (GPIO 5) of ESP32.
  • Connect LED 2 to D18 (GPIO 18) of ESP32.
  • Connect LED 3 to D 19 (GPIO 19) of ESP32.
  • Connect LED 4 to D 21 (GPIO 21) of ESP32.

IN BLYNK


CODE

#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

BlynkTimer timer;

// OUTPUT PIN'S
#define led1 5
#define led2 18
#define led3 19
#define led4 21

// PWM PIN
#define led 2

// VARIABLE FOR PWM IN ESP32
const int freq = 5000;
const int ledChannel = 0;
const int resolution = 8;

// AUTHENTICATION TOKEN WHICH WILL BE SEND TO YOUR RESISTERED EMAIL ID 
char auth[] = "-----------------------";

// FOR ESP32 TO CONNECT TO ROUTER TO INTERNET
char ssid[] = "----------"; // WIFI NAME
char pass[] = "----------"; // WIFI PASSWORD

// BUTTON'S ON BLYNK APP
BLYNK_WRITE(V0)
{
  int pinValue = param.asInt(); 
  digitalWrite(led1, pinValue);
}

BLYNK_WRITE(V1)
{
  int pinValue = param.asInt();
  digitalWrite(led2, pinValue);
}

BLYNK_WRITE(V2)
{
  int pinValue = param.asInt();
  digitalWrite(led3, pinValue);
}

BLYNK_WRITE(V3)
{
  int pinValue = param.asInt();
  digitalWrite(led4, pinValue);
}

// SLIDER ON BLYNK
BLYNK_WRITE(V4)
{
  int pinValue = param.asInt();
 ledcWrite(ledChannel,pinValue);
}

void setup()
{
// SET PIN'S AS OUTPUT
  pinMode(led1 ,OUTPUT);
  pinMode(led2 ,OUTPUT);
  pinMode(led3 ,OUTPUT);
  pinMode(led4 ,OUTPUT);
  pinMode(led ,OUTPUT);  
  
  Serial.begin(9600); // BEGIN SERIAL COMMUNICATION
  WiFi.begin(ssid, pass); // ESP32 TO CONNECT TO YOUR WIFI
  Blynk.config(auth); // FOR CONNECT TO BLYNK SERVER

// FOR PWM
  ledcSetup(ledChannel, freq, resolution);
  ledcAttachPin(led, ledChannel);
}

void loop(){
      Blynk.run(); // TO START THE BLYNK SERVER TO COMMUNICATE WITH ESP32
}
SUBSCRIBE TO "scientist BENIEL'S LAB" IN YOUTUBE FOR MORE ELECTRONIC'S & ROBOTIC'S PROJECTS.
THANK YOU

Comments

Post a Comment

Popular posts from this blog

Arduno Clock

  Arduino Clock This is a clock using RTC Tiny with Arduino. Using this we can see time & date.  FOR VIDEO :

MQ-5 GAS LEAK DETECTOR

  MQ-5 GAS LEAK DETECTOR  This project is used to detect the gas leak and alert us that the gas is leaking. You can use it for your science projects. FOR VIDEO :

Blutooth Switch (Arduino)

 BLUTOOTH SWITCH (ARDUINO) Hi, Using this we can control leds using Smart Phone via Blutooth. We can also control home appliances using Relay with it. For Video :  CLICK HERE  .