DIY Fingerprint-Secured Cardboard Safe

by tech_nickk in Circuits > Arduino

16 Views, 0 Favorites, 0 Comments

DIY Fingerprint-Secured Cardboard Safe

IMG-20250414-WA0024.jpg
IMG-20250414-WA0019.jpg
IMG-20250414-WA0018.jpg
IMG-20250414-WA0020.jpg
IMG-20250414-WA0022.jpg
IMG-20250414-WA0024.jpg
IMG-20250414-WA0026.jpg
IMG-20250414-WA0033.jpg

Introduction

Do you have small valuables you want to keep secure? In this Instructable, I'll show you how to build a fingerprint-secured cardboard safe using affordable electronic components. This project combines basic cardboard construction with electronics to create a functional safe that only opens for your fingerprint.


Project Overview:

  1. A cardboard safe secured with biometric (fingerprint) authentication
  2. OLED display for system status and instructions
  3. Servo motor locking mechanism
  4. Push button for lock/unlock operations
  5. Perfect weekend project for beginners in electronics


Supplies

Electronics:

  1. ESP32 microcontroller
  2. Adafruit Fingerprint Sensor
  3. SSD1306 0.96" OLED I2C Display
  4. Micro Servo Motor (SG90 or similar)
  5. Momentary Push Button
  6. Jumper Wires
  7. Mini Breadboard (optional)
  8. USB-C Cable (for programming and power)
  9. 5V Power Supply (if not using USB)

Construction Materials:

  1. Corrugated Cardboard (Amazon boxes work great!)
  2. Hot Glue Gun & Glue Sticks
  3. Box Cutter or Craft Knife
  4. Ruler
  5. Pencil
  6. Clear Tape
  7. Masking or Painter's Tape

Tools:

  1. Soldering Iron & Solder (optional but recommended)
  2. Wire Cutters/Strippers
  3. Computer with Arduino IDE

Design and Build the Cardboard Safe

IMG-20250414-WA0038.jpg
IMG-20250414-WA0040.jpg
IMG-20250414-WA0041.jpg
IMG-20250414-WA0043.jpg
IMG-20250414-WA0045.jpg

Now it's time to build the physical safe!

Basic Design:

  1. For a simple box design, you'll need six cardboard pieces:
  2. Front: 15cm × 6cm
  3. Back: 15cm × 6cm
  4. Left side: 10cm × 6cm
  5. Right side: 10cm × 6cm
  6. Bottom: 15cm × 8cm
  7. Top (lid):15cm × 8cm

Construction Steps:

  1. Cut all pieces according to the dimensions above
  2. Use masking tape to connect the front, sides, and back, forming a rectangular frame
  3. Attach the bottom piece using tape or hot glue
  4. Create a hinge for the top lid using clear tape along one edge
  5. Reinforce all edges with additional tape for durability

Component Mounting:

  1. Cut a small rectangular hole in the front panel for the fingerprint sensor
  2. Cut a circular hole for the OLED display above or next to the fingerprint sensor
  3. Create a hole for the button on the front panel
  4. Mount the servo motor inside the box, positioned to block the lid when activated
  5. Secure all components with hot glue

Create the Locking Mechanism

The servo motor will act as the locking mechanism for your safe:

  1. Cut a small piece of cardboard or plastic to act as a latch
  2. Attach this piece to the middle of the lid using hot glue
  3. Position the servo so that when it's at 0 degrees, the latch blocks the lid from opening
  4. When the servo rotates to 90 degrees, the servo arm should move away, allowing the lid to open
  5. Test the mechanism manually by moving the servo arm before connecting it to power

Wire the Components

Now let's connect all the electronic components:

Fingerprint Sensor:

  1. VCC → 3.3V on ESP32
  2. GND → GND on ESP32
  3. TX → Pin 16 on ESP32
  4. RX → Pin 17 on ESP32

OLED Display:

  1. VCC → 3.3V on ESP32
  2. GND → GND on ESP32
  3. SDA → SDA pin on ESP32 (default GPIO 21)
  4. SCL → SCL pin on ESP32 (default GPIO 22)

Servo Motor:

  1. Signal (usually orange or yellow) → Pin 18 on ESP32
  2. Red → 5V (External power recommended for stability)
  3. Brown/Black → GND

Button:

  1. Connect one terminal to GND
  2. Connect the other terminal to Pin 19 on ESP32

Wiring Tips:

  1. Use different colored wires to avoid confusion
  2. Double-check connections before powering on
  3. Consider using a mini breadboard for easier connections
  4. For a more permanent build, solder the connections or use a custom PCB


Assemble and Install Electronics

IMG-20250414-WA0035.jpg
IMG-20250414-WA0036.jpg
IMG-20250414-WA0037.jpg

Now it's time to put everything together:

  1. Mount the ESP32 inside the box, ideally on the side or back panel
  2. Secure the fingerprint sensor in its cutout using hot glue
  3. Mount the OLED display in its position
  4. Install the push button in its hole
  5. Arrange all wiring neatly inside the box, using tape to secure if needed
  6. If using external power, create a small hole for the power cable

Install Required Libraries

let's set up the software environment:

  1. Install Arduino IDE from arduino.cc
  2. Add ESP32 board support:
  3. Open Arduino IDE
  4. Go to File > Preferences
  5. In "Additional Boards Manager URLs", add: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
  6. Go to Tools > Board > Boards Manager
  7. Search for "esp32" and install "ESP32 by Espressif Systems"
  8. Install required libraries via Sketch > Include Library > Manage Libraries:
  9. Adafruit SSD1306
  10. Adafruit GFX Library
  11. Adafruit Fingerprint Sensor Library
  12. ESP32Servo


Upload the Code

  1. Open Arduino IDE
  2. Create a new sketch and paste the following code:


#include <Wire.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_Fingerprint.h>
#include <ESP32Servo.h>
#include <EEPROM.h>

// OLED Display settings
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

// Fingerprint sensor settings
#define FINGERPRINT_RX 16 // Connect to TX on fingerprint sensor
#define FINGERPRINT_TX 17 // Connect to RX on fingerprint sensor
HardwareSerial fingerSerial(1);
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&fingerSerial);

// Servo settings
#define SERVO_PIN 18
Servo lockServo;

// Button settings
#define BUTTON_PIN 19
int lastButtonState = HIGH; // Assuming pull-up resistor

// States
bool isLocked = true;
bool isEnrolled = false;
unsigned long lastDebounceTime = 0;
unsigned long debounceDelay = 50;

void setup() {
Serial.begin(115200);
// Initialize EEPROM
EEPROM.begin(10);
// Initialize fingerprint sensor
fingerSerial.begin(57600, SERIAL_8N1, FINGERPRINT_RX, FINGERPRINT_TX);
// Initialize OLED
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(SSD1306_WHITE);
// Initialize servo
ESP32PWM::allocateTimer(0);
lockServo.setPeriodHertz(50);
lockServo.attach(SERVO_PIN, 500, 2500);
lockServo.write(0); // Start locked
// Initialize button pin
pinMode(BUTTON_PIN, INPUT_PULLUP);
// Show welcome message
displayMessage("Fingerprint Safe", "Initializing...");
delay(1000);
// Initialize fingerprint sensor
if (finger.verifyPassword()) {
displayMessage("Sensor Ready", "");
} else {
displayMessage("Sensor Failed", "Check wiring!");
while (1) delay(1000);
}
// Check if fingerprint is enrolled
isEnrolled = EEPROM.read(0);
if (!isEnrolled) {
displayMessage("No fingerprint", "registered");
delay(2000);
enrollFingerprint();
} else {
displayMessage("System Ready", "Scan to unlock");
}
}

void loop() {
// Check button state for lock/unlock action
int buttonState = digitalRead(BUTTON_PIN);
if (buttonState != lastButtonState) {
lastDebounceTime = millis();
}
if ((millis() - lastDebounceTime) > debounceDelay) {
// If the button state has changed and is pressed
if (buttonState == LOW) {
if (isLocked) {
// Only allow unlock if fingerprint was verified
if (checkFingerprint()) {
unlockSafe();
} else {
displayMessage("Access Denied", "Try again");
}
} else {
// Lock if already unlocked
lockSafe();
}
}
}
lastButtonState = buttonState;
// If system is waiting for first fingerprint enrollment
if (!isEnrolled) {
enrollFingerprint();
}
delay(100);
}

bool checkFingerprint() {
displayMessage("Place finger", "on sensor");
uint8_t p = finger.getImage();
if (p != FINGERPRINT_OK) return false;
p = finger.image2Tz();
if (p != FINGERPRINT_OK) return false;
p = finger.fingerFastSearch();
if (p != FINGERPRINT_OK) return false;
// Found a match!
displayMessage("Fingerprint", "Verified!");
delay(1000);
displayMessage("Press button", "to unlock");
return true;
}

void enrollFingerprint() {
displayMessage("New User Setup", "Place finger");
delay(2000);
int id = 1; // We'll use ID #1 for the single authorized user
while (!getFingerprintEnroll(id)) {
delay(1000);
}
// Mark as enrolled in EEPROM
EEPROM.write(0, 1);
EEPROM.commit();
isEnrolled = true;
displayMessage("Enrollment", "Complete!");
delay(2000);
displayMessage("System Ready", "Scan to unlock");
}

bool getFingerprintEnroll(uint8_t id) {
int p = -1;
displayMessage("Waiting for", "valid finger");
while (p != FINGERPRINT_OK) {
p = finger.getImage();
switch (p) {
case FINGERPRINT_OK:
displayMessage("Image taken", "");
break;
case FINGERPRINT_NOFINGER:
displayMessage("Waiting for", "finger...");
break;
case FINGERPRINT_PACKETRECIEVEERR:
displayMessage("Communication", "error");
break;
case FINGERPRINT_IMAGEFAIL:
displayMessage("Imaging error", "");
break;
default:
displayMessage("Unknown error", String(p));
break;
}
}

// Convert image to template
p = finger.image2Tz(1);
if (p != FINGERPRINT_OK) {
displayMessage("Template error", String(p));
return false;
}
displayMessage("Remove finger", "");
delay(2000);
p = 0;
while (p != FINGERPRINT_NOFINGER) {
p = finger.getImage();
}
displayMessage("Place same", "finger again");
p = -1;
while (p != FINGERPRINT_OK) {
p = finger.getImage();
if (p == FINGERPRINT_OK) {
displayMessage("Image taken", "");
}
}

// Convert image to template
p = finger.image2Tz(2);
if (p != FINGERPRINT_OK) {
displayMessage("Template error", String(p));
return false;
}
// Create model
p = finger.createModel();
if (p != FINGERPRINT_OK) {
displayMessage("Model error", String(p));
return false;
}
// Store model
p = finger.storeModel(id);
if (p != FINGERPRINT_OK) {
displayMessage("Storage error", String(p));
return false;
}
return true;
}

void unlockSafe() {
displayMessage("Unlocking...", "");
lockServo.write(90); // Move servo to unlocked position
isLocked = false;
delay(500);
displayMessage("Safe Unlocked", "Press to lock");
}

void lockSafe() {
displayMessage("Locking...", "");
lockServo.write(0); // Move servo to locked position
isLocked = true;
delay(500);
displayMessage("Safe Locked", "Scan to unlock");
}

void displayMessage(String line1, String line2) {
display.clearDisplay();
display.setCursor(0, 10);
display.println(line1);
display.setCursor(0, 30);
display.println(line2);
display.display();
Serial.println(line1 + " " + line2); // Also output to serial for debugging
}
  1. Select your board: Tools > Board > ESP32 Arduino > ESP32 Dev Module
  2. Select the correct port: Tools > Port > (select your ESP32's port)
  3. Upload the code by clicking the Upload button (right arrow)


Test the System

IMG-20250414-WA0028.jpg
IMG-20250414-WA0030.jpg
IMG-20250414-WA0031.jpg
IMG-20250414-WA0032.jpg
IMG-20250414-WA0033.jpg

Before sealing everything up:

  1. Power on the system using USB or external power
  2. The OLED should display "Fingerprint Safe" followed by initialization messages
  3. For first-time setup, follow the onscreen prompts to register your fingerprint
  4. Test the locking mechanism by scanning your finger and pressing the button
  5. Make any necessary adjustments to the servo position or latch design


Final Assembly and Customization

IMG-20250414-WA0022.jpg
IMG-20250414-WA0023.jpg
IMG-20250414-WA0024.jpg
IMG-20250414-WA0025.jpg
  1. Once everything is working correctly, secure all internal components with hot glue
  2. Add additional cardboard reinforcement to areas that might need strengthening
  3. Consider waterproofing the electronics area with a layer of clear tape
  4. Personalize your safe by painting or decorating the exterior

Optional Enhancements:

  1. Add a battery pack for portable operation
  2. Install LEDs for visual feedback (green for successful unlock, red for denied)
  3. Add a simple alarm that sounds if incorrect fingers are scanned multiple times


How to Use Your Fingerprint Safe

First Time Setup:

  1. Power on the safe
  2. The OLED will prompt you to register your fingerprint
  3. Place your finger on the sensor when instructed
  4. Remove and replace your finger when prompted for the second scan
  5. Wait for confirmation that enrollment is complete

Normal Operation:

  1. To unlock: Place your registered finger on the sensor, then press the button
  2. The servo will rotate 90 degrees, allowing the lid to open
  3. To lock: Press the button again
  4. The servo will return to 0 degrees, securing the lid


Troubleshooting

Fingerprint Sensor Not Responding:

  1. Check wiring connections, especially TX/RX crossed connections
  2. Ensure the sensor is receiving 3.3V power
  3. Try cleaning the sensor surface with a soft cloth

Servo Not Moving:

  1. Check wiring and power supply (servos may need more current than USB can provide)
  2. Verify that it's properly connected to pin 18
  3. Test the servo independently using a simple sweep code

OLED Display Issues:

  1. Verify I2C address (0x3C is most common, but some displays use 0x3D)
  2. Check SDA/SCL connections
  3. Ensure proper voltage (3.3V)

System Resets or Crashes:

  1. Use an external 5V power supply instead of USB
  2. Add a capacitor (100-470μF) between power and ground to stabilize voltage
  3. Reduce servo movement speed in code


Conclusion

Congratulations! You've built your own fingerprint-secured cardboard safe. While not meant for high-security applications, this project demonstrates the principles of biometric authentication and electronic locking mechanisms in a fun and educational way.

This project combines skills in electronics, programming, and basic construction, making it perfect for hobbyists, students, or anyone interested in learning about security systems. Feel free to modify and enhance the design to suit your specific needs!

Safety Notes:

  1. This project uses low voltage and is generally safe, but always be careful with electrical connections
  2. Use caution when working with hot glue and cutting tools
  3. This is designed as an educational project and not for securing valuable items

Happy making :)