How to make IoT Door Lock with ESP32

This IoT door lock has one solenoid lock and an MC38 sensor controlled by the Blynk app using ESP32. The sensor gives real-time data on the door and the solenoid is used to lock the door. 

To do this project we need to follow these steps.

Step1

Watch the YouTube video

Step2

Installing ESP32 Add-on in Arduino IDE

To install the ESP32 board in your Arduino IDE, follow these next instructions:

In your Arduino IDE, go to FilePreferences

  • In your Arduino IDE, go to FilePreferences

Note: if you already have the ESP8266 board URL, you can separate the URLs with a comma as follows:

https://dl.espressif.com/dl/package_esp32_index.json, http://arduino.esp8266.com/stable/package_esp8266com_index.json

Open the Boards Manager. Go to Tools > Board > Boards Manager…

  • Open the Boards Manager. Go to Tools > Board > Boards Manager…
  • Search for ESP32 and press the install button for the “ESP32 by Espressif Systems“:
  • That’s it. It should be installed after a few seconds.

Step 3

1. Install Blynk Library using the built-in library manager in Arduino IDE

To install a new library into your Arduino IDE, you can use the Library Manager (available from IDE version 1.6.2). Open the IDE and click on the “Sketch” menu and then Include Library > Manage Libraries.

Then the Library Manager will open, and you will find a list of already installed or ready for installation. Search for Blynk library and in the version, selection choose the latest version to date

Finally, click on Install and wait for the IDE to install the new library. Downloading may take time depending on your connection speed. Once it has been finished and Installed tag should appear next to the Bridge library. You can close the library manager.

You can now find the new library available in the Sketch > Include Library menu. 

Step 4

The circuit looks like this.

Step 5

The PCB was designed using easyeda software and it looks like this. 

And it was ordered from the JLCPCB website using this link 

$2 for 1-4 Layer PCBs, Get Free SMT Coupons →https://jlcpcb.com/IYB 

Step 6

Now follow the steps provided in the video to download the Blynk app and upload the code. And Enjoy your door lock. You can also checkout other project such as How to make Line Follower Robot with Arduino

#define BLYNK_PRINT Serial

/* Fill-in your Template ID (only if using Blynk.Cloud) */
//#define BLYNK_TEMPLATE_ID   "YourTemplateID"


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

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

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

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

  Blynk.begin(auth, ssid, pass);
}

void loop()
{
  Blynk.run();
  state = digitalRead(15);
  if(state != pstate)
  {
    Blynk.virtualWrite(V1,state);
    pstate = state;
  }
}

8 thoughts on “How to make IoT Door Lock with ESP32”

Leave a Comment