1. Node MCU Ver 0.9
2. Solenoid lock
3. H-bridge
Step 2. Code work#include <ESP8266WiFi.h>
#include <ESPAsyncTCP.h>
#include <ESPAsyncWebServer.h>
const char* ssid = "Engineer2you-Home";
const char* password = "123456789";
IPAddress apIP(72, 72, 72, 72); // Defining a static IP address
int output_value_lock = 0;
int socket_data = 0;
const int ledPin_lockPin = 2;
int password_state_typing = 0;
int password_state_wrong = 0;
int password_key = 0;
// Create AsyncWebServer object on port 80
AsyncWebServer server(80);
AsyncWebSocket ws("/ws");
const char index_html[] PROGMEM = R"rawliteral(
<!DOCTYPE HTML><html>
<head>
<title>Wifi lock</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="data:,">
<style>
html {
font-family: Arial, Helvetica, sans-serif;
text-align: center;
}
h1 {
font-size: 1.8rem;
color: white;
}
....
to get the final code, please email to me baank83@gmail.com
Step 3. Test runAfter compile and download the code, ESP8266 will be a Wifi station (Access Point).
Now you can use smart phone to connect to wifi station named Engineer2you-Home with password is "123456789" (Of-course you can edit the name and password in Arduino code)
After connection successful, go to web browser on phone and type address 72.72.72.72 (again, you can also edit this address in Arduino code). The web screen of lock status will appeared!
Press "door button" |]||[ : if lock is opened, it will close the lock (without password)
Input password to open the lock: password is "123456", ofcourse you can change this password in Arduino code. If wrong password, you can not open the lock.
Step 4. Make circuit and installationI made small home model, then install solenoid lock, "WIFI LOCK" controller box, then test again. It works fine!
Then I print QR-Code for address 72.72.72.72 and stick on door. Imagine that, you get home, use the phone to scan QR-Code and input password to open the door, so cool! haha
Step 5. FinishedLet's see the final for beautiful works
Watch the video to see finished works
Comments