All work
IoT lock2024

Smart Safe

A working safe that opens with a keypad code or remotely from a phone.

Year
2024
Team
Team of five
My role
Firmware, Blynk app, schematics and wiring
Built with
ESP32, C++, Blynk, Wokwi
4×4
keypad, code entry
12 V
solenoid lock via relay
3
wrong tries trigger the siren
4
circuits simulated first

/demo

The finished safe, opening for real

/try-it

Try the safe yourself

This runs the same logic as our ESP32 firmware: the same keypad, password, messages and alarm. The phone on the right is the lock page the safe serves over its own Wi-Fi.

Enter Password:
Solenoid lockedBuzzer

Try it: the code is 2021, * deletes, # enters. Press # with nothing typed to lock. Three wrong codes set off the alarm. Wrong tries so far: 0.

192.168.1.1 · ESP_AP

Lock Control

The page the ESP32 serves over its own Wi-Fi hotspot.

/my-part

What I did on a team of five

  • Firmware

    Wrote the main safe code: keypad input, password check, LCD messages, relay control and the alarm.

  • Remote control

    Wrote the Blynk code for unlocking from a phone. The final build serves its own lock page over Wi-Fi.

  • Schematics

    Drew the circuit schematics for the relay and solenoid, the keypad and the I2C LCD.

  • Hardware

    Chose the components, then soldered, wired and assembled them into the safe.

/simulate-first

Simulated on Wokwi before touching a soldering iron

Each part got its own simulation first, so wiring mistakes cost nothing. The links open our original Wokwi projects.

The prototype on a breadboard: ESP32, relay, solenoid lock, LCD, keypad and battery pack
The breadboard prototype: ESP32, relay, solenoid, I2C LCD, keypad and battery pack.
Schematic of the relay switching a 12-volt battery into the solenoid lock
My schematic for the relay stage: the ESP32 switches the relay, which switches 12 V into the solenoid.

/code

The code behind the keypad

smart_safe.ino
1void Keypad()
2{
3 char key = keypad.getKey();
4 if (key) {
5 if (key == '#') {
6 checkAndProcessPassword(key);
7 } else if (key == '*' && enteredPassword.length() > 0) {
8 // '*' works as backspace
9 enteredPassword.remove(enteredPassword.length() - 1);
10 lcd.setCursor(enteredPassword.length(), 1);
11 lcd.print(" ");
12 lcd.setCursor(enteredPassword.length(), 1);
13 } else {
14 clearLCD();
15 enteredPassword += key;
16 lcd.print(enteredPassword);
17 }
18 }
19}
20
21void checkAndProcessPassword(char key) {
22 if (checkPassword()) {
23 lcd.setCursor(0, 1);
24 lcd.print("Access Granted");
25 digitalWrite(relayPin, HIGH); // Open the relay
26 delay(2000);
27 clearLCD();
28 incorrectAttempts = 0;
29 deactivateBuzzer();
30 }
31 else if (checkPassword() == false && key == '#' && enteredPassword == "") {
32 lcd.setCursor(0, 1);
33 lcd.print("Safe is Locked");
34 digitalWrite(relayPin, LOW);
35 delay(2000);
36 deactivateBuzzer();
37 clearLCD();
38 }
39 else {
40 lcd.setCursor(0, 1);
41 lcd.print("Access Denied");
42 analogWrite(buzzerPin, 255);
43 locker();
44 delay(1000);
45 incorrectAttempts++;
46 deactivateBuzzer();
47 printLcd();
48 if (incorrectAttempts >= 3) {
49 activateBuzzer(); // Siren sweep, 500 to 600 Hz
50 police();
51 delay(1000);
52 incorrectAttempts = 0;
53 deactivateBuzzer();
54 printLcd();
55 }
56 }
57 enteredPassword = ""; // Clear the entered password
58}
smart_safe.ino · web server
1// The safe runs its own Wi-Fi hotspot and serves a lock page
2WiFi.softAP(ssid, password);
3WiFi.softAPConfig(local_ip, gateway, subnet); // 192.168.1.1
4server.on("/", handle_OnConnect);
5server.on("/Open", handle_Opened);
6server.on("/Closed", handle_Closed);
7server.onNotFound(handle_NotFound);
8server.begin();
9
10void handle_Opened() {
11 digitalWrite(relayPin, HIGH);
12 server.send(200, "text/html", getHTML());
13}
14
15void handle_Closed() {
16 digitalWrite(relayPin, LOW);
17 server.send(200, "text/html", getHTML());
18}

What went wrong, and the fix

ESP32 connectivity, wiring mistakes and keypad bugs cost us time. The fix was reading the exact datasheet for each part and simulating every circuit before wiring it, so we didn’t burn out components.

/contact

Let’s design and build something people love using.

I’m looking for a UI/UX or frontend role on a team that ships. Email is the fastest way to reach me.

© 2026 Mayar Mohamed Issa. Designed and built by me, with Next.js, Tailwind CSS and Motion.