Hackster is hosting Impact Spotlights highlighting smart energy storage. Start streaming on Thursday!Stream Impact Spotlights on Thursday!
adarsh bhola
Published © GPL3+

IOT based Door lock system

It is an IOT based door lock system which consists of a NodeMCU board. It is interfaced with a Sg90 which shows open and close of a door lock

BeginnerFull instructions provided2 hours19,529
IOT based Door lock system

Things used in this project

Hardware components

NodeMCU ESP8266 Breakout Board
NodeMCU ESP8266 Breakout Board
×1
Resistor 10k ohm
Resistor 10k ohm
×1
Pushbutton switch 12mm
SparkFun Pushbutton switch 12mm
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1

Software apps and online services

Blynk
Blynk
Arduino IDE
Arduino IDE
circuito.io
circuito.io

Story

Read more

Schematics

Circuit diagram

It is the schematic of the whole circuit

Code

IOT based Door Lock system

Arduino
It is the code for the whole project
#define BLYNK_PRINT Serial
#define LED D4

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Servo.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "Your Auth token";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Wifi SSID";
char pass[] = "Wifi password";

Servo servo;

uint8_t BUTTON=D2;
bool door;
int pos;

BLYNK_WRITE(V3)
{
  int pinValue=param.asInt();
  if(pinValue==1)
  {
      for (pos = 0; pos <= 180; pos += 5) { 
        servo.write(pos);              
        delay(15);
      }
      digitalWrite(LED,HIGH);                                                           //INVERTED STATUS OF LED PINS:HIGH means LOW
      door=true;
      Blynk.email("adarshbhola98@gmail.com","door_lock_unlock status","Door is closed");
  }
  else
  {
    for (pos = 180; pos >= 0; pos -= 5) { 
      servo.write(pos);              
      delay(15);
    }
    digitalWrite(LED,LOW);                                                          //LOW-->HIGH
    door=false;
    Blynk.email("adarshbhola98@gmail.com","door_lock_unlock status","Door is open");
  }
}

void IntCallback()
{
  if(door==false)
  {
      for (pos = 0; pos <= 180; pos += 5) { 
        servo.write(pos);              
        delay(15);
      }
      digitalWrite(LED,HIGH);                                                           //INVERTED STATUS OF LED PINS:HIGH means LOW
      door=true;
  }
  else
  {
    return;
  }
}

void setup()
{
  // Debug console
  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);

  servo.attach(15);     //15--->D8
  pinMode(LED,OUTPUT);
  attachInterrupt(digitalPinToInterrupt(BUTTON),IntCallback,RISING);
}

void loop()
{
  Blynk.run();
}

Credits

adarsh bhola

adarsh bhola

10 projects • 8 followers
I am a student at VIT University,chennai campus.I have been developing for 2 years.I got started in embedded systems through 8051 uc

Comments