From 79e9eec0ac05634fe367220df701b20c91523291 Mon Sep 17 00:00:00 2001 From: Sadeep Madurange Date: Sat, 25 Oct 2025 10:53:52 +0800 Subject: Project folder. --- _projects/fpm-door-lock/breadboard.jpg | Bin 0 -> 46771 bytes _projects/fpm-door-lock/footprint.png | Bin 0 -> 198127 bytes _projects/fpm-door-lock/gerber.zip | Bin 0 -> 89431 bytes _projects/fpm-door-lock/index.md | 112 +++++++++++++++++++++++++++++++++ _projects/fpm-door-lock/pcb.jpg | Bin 0 -> 68237 bytes _projects/fpm-door-lock/pcb1.jpg | Bin 0 -> 37068 bytes _projects/fpm-door-lock/source.tar.gz | Bin 0 -> 29473 bytes _projects/fpm-door-lock/video.mp4 | Bin 0 -> 13264594 bytes 8 files changed, 112 insertions(+) create mode 100644 _projects/fpm-door-lock/breadboard.jpg create mode 100644 _projects/fpm-door-lock/footprint.png create mode 100644 _projects/fpm-door-lock/gerber.zip create mode 100644 _projects/fpm-door-lock/index.md create mode 100644 _projects/fpm-door-lock/pcb.jpg create mode 100644 _projects/fpm-door-lock/pcb1.jpg create mode 100644 _projects/fpm-door-lock/source.tar.gz create mode 100644 _projects/fpm-door-lock/video.mp4 (limited to '_projects/fpm-door-lock') diff --git a/_projects/fpm-door-lock/breadboard.jpg b/_projects/fpm-door-lock/breadboard.jpg new file mode 100644 index 0000000..2bf47a9 Binary files /dev/null and b/_projects/fpm-door-lock/breadboard.jpg differ diff --git a/_projects/fpm-door-lock/footprint.png b/_projects/fpm-door-lock/footprint.png new file mode 100644 index 0000000..5511bf1 Binary files /dev/null and b/_projects/fpm-door-lock/footprint.png differ diff --git a/_projects/fpm-door-lock/gerber.zip b/_projects/fpm-door-lock/gerber.zip new file mode 100644 index 0000000..19a9d19 Binary files /dev/null and b/_projects/fpm-door-lock/gerber.zip differ diff --git a/_projects/fpm-door-lock/index.md b/_projects/fpm-door-lock/index.md new file mode 100644 index 0000000..72fd171 --- /dev/null +++ b/_projects/fpm-door-lock/index.md @@ -0,0 +1,112 @@ +--- +title: Prototype fingerprint door lock +date: 2025-10-03T00:00:00+08:00 +author: W. D. Sadeep Madurange +--- + +This project features a fingerprint door lock powered by an ATmega328P +microcontroller. + + + +## Overview + +The lock comprises three subsystems: the ATmega328P, an R503 fingerprint +sensor, and an FS5106B high-torque servo. The sensor mounted on the front +surface of the door enables users to unlock it from the outside. The servo is +attached to the interior door knob. The MCU must be installed at the back of +the door to prevent unauthorized users from tampering with it. + +When no one is interacting with the lock, the MCU is in deep sleep. The sensor +and the servo each draw 13.8 mA and 4.6 mA of quiescent currents. To prevent +this idle current draw, the MCU employs MOSFETs to cut off power to them before +entering deep sleep. Doing so is crucial for conserving the battery. + +Without power, the sensor remains in a low-power state, drawing approximately +2.9 μA through a separate power rail. When a finger comes into contact with the +sensor, the sensor triggers a pin change interrupt, waking up the MCU. The MCU +activates a MOSFET, which in turn activates the sensor. Over UART, the MCU +unlocks the sensor and issues commands to scan and match the fingerprint. + +If the fingerprint matches an enrolled fingerprint, the MCU activates the blue +LED on the sensor, turns on the MOSFET connected to the servo, and sends a PWM +signal to the servo to unlock the door. Otherwise, the MCU activates the red +LED on the sensor. Finally, the MCU deactivates the MOSFETS and goes back to +sleep. + +## Embedded software + +The embedded software, written in C with the help of the AVR toolchain, +includes a driver for the sensor, servo control routines, and a battery +monitoring system. + +In addition to controlling the sensor and the servo, the program strives to +maintain precise control over the sleep mode, as well as when the peripherals +are activated and for how long they remain active. I thoroughly enjoyed writing +the embedded software. There's something magical about being able to alter the +physical world around you by uttering a few lines of C code. + +The source code of the project, which includes a driver for the R503 +fingerprint sensor module, is enclosed in the tarball linked at the end of the +page. + +## The circuit board + +For this project, I designed a custom PCB and had it fabricated by JLCPCB. Like +the software, the circuit is chiefly concerned with optimizing power +consumption and extending battery life. + + + + + + + + + +
+ PCB + + Design +
+ PCB footprint +
+ +To that end, the principal components of the circuit are the 2N7000 and +NDP6020P field-effect transistors. They switch power electronically to the +servo and the fingerprint sensor, the two most power-hungry parts of the +circuit. The two MP1584EN buck converters play an axial role in efficiently +regulating power to the MCU and the sensor. + +The ATmega328P typically operates at 5 V with a 16 MHz crystal oscillator. To +further reduce power consumption, I modified the ATmega328P's fuses to run at +3.3 V with an 8 MHz crystal oscillator. + +The bottom right area of the PCB isolates the power supply of the servo from +the rest of the circuit. This shields components such as the MCU from the +servo's high current draw, which can exceed 1 A. The IN4007 diode in slot U2 +serves as a flyback diode, protecting the MOSFET from reverse currents +generated by the servo. + +Lastly, the 56 kΩ and 10 kΩ resistors in slots R10 and R11 form a voltage +divider circuit. Its output is fed to the ADC of the MCU, which measures the +supply voltage by comparing it to the internal bandgap reference voltage. + +## Epilogue + +This project began nearly a year ago when I attempted to unlock our door +wirelessly by writing to the UART ports of two MCUs connected to inexpensive +433 MHz RF transceivers, as if there were an invisible wire between them. +Although I failed, it led me down a rabbit hole of RF communications, MOSFETs, +PCB design, and low-power circuits. + +During the project, I reinvented the wheel many times. I implemented a +low-level network stack using only RF modules and an 8-bit microcontroller, +designed my first PCB, and developed drivers from scratch. The project was far +from a smooth sail. Bad electrical connections, soldering, desoldering, and the +heartache of purchasing the wrong parts were routine. It was a long but +rewarding journey from the messy breadboard to the shiny PCB. + +Files: [source.tar.gz](source.tar.gz), [gerber.zip](gerber.zip) diff --git a/_projects/fpm-door-lock/pcb.jpg b/_projects/fpm-door-lock/pcb.jpg new file mode 100644 index 0000000..fbd800b Binary files /dev/null and b/_projects/fpm-door-lock/pcb.jpg differ diff --git a/_projects/fpm-door-lock/pcb1.jpg b/_projects/fpm-door-lock/pcb1.jpg new file mode 100644 index 0000000..367187d Binary files /dev/null and b/_projects/fpm-door-lock/pcb1.jpg differ diff --git a/_projects/fpm-door-lock/source.tar.gz b/_projects/fpm-door-lock/source.tar.gz new file mode 100644 index 0000000..ef23422 Binary files /dev/null and b/_projects/fpm-door-lock/source.tar.gz differ diff --git a/_projects/fpm-door-lock/video.mp4 b/_projects/fpm-door-lock/video.mp4 new file mode 100644 index 0000000..a907a9b Binary files /dev/null and b/_projects/fpm-door-lock/video.mp4 differ -- cgit v1.2.3