Time Safe Lock Box


This page covers my Time Safe lock box project.
Time Safe is an ATtiny85-based time-lock safe with configurable unlock windows, designed for makers using KiCad and the Arduino toolchain. It can only be unlocked during user-configurable time windows and is intended as a self-control aid — for example, to restrict access to snacks while dieting or to help manage access to prescription medication to reduce the risk of overuse.
The project combines a custom PCB designed in KiCad 9.0 with firmware for an ATtiny85-20, driving an electronic latch, an OLED display, and a 4x4 keypad. Version 1.0 is fully working as a hand-assembled prototype, with PCBs fabricated by JLCPCB. Details are available on the GitHub page in the README.md file, and portions are included below for completeness:
https://github.com/avose/TimeSafe
https://github.com/avose/TimeSafe/blob/master/README.md
The repository includes the full schematic and PCB layout as a KiCad project along with the complete firmware used on the ATtiny85 micro controller.
Features
- 5-digit PIN authentication for admin access, with the PIN stored in EEPROM so it persists across power cycles.
- Four configurable unlock time windows, each defined by a start and end DateTime structure stored in EEPROM.
- Wildcard support in window definitions to allow flexible patterns such as "any day at a certain time" or "every Monday in a
given time range".
- Real-time clock (RTC) based on the PCF85263A, with date and time settable from the front-panel menu (no external programmer or PC required to
change time). Battery backup power is provided to the RTC to keep the time even when the device is off. For my prototype build, I added an electronic key switch to control power to the board, so the battery backup for the RTC is critical.
- Admin override: an authenticated admin can always unlock the safe regardless of the currently active time windows.
- Front-panel UI using a 4×4 matrix keypad and a 128×64 SSD1306 OLED driven through a compact text-only library, providing a simple and intuitive menu system. -- For navigating the menu interface, the A key is used like an enter key, B is back, C is previous, and D is next.
- Menu states for locked view, PIN entry, admin menu, time editing, window configuration, and PIN change, with a 1-minute auto-logout back to the locked state to protect admin mode.
- Electronic latch control implemented via timed charge and discharge of a driver circuit, coordinated in firmware to pulse the latch reliably. Common electronic latches like the cheap ones I found on AliExpress may be compatible with 5V, but then generally need something like 2A to drive the latch coil. This is a bit more current than most supplies are rated for, so this design uses a pair of MOSFETs to control the charge and discharge of some capacitors which then provide a pulse with enough current to open the latch. This design eliminates the need to do anything special with the power supply circuitry; something more like 5V @ 500mA is sufficient.
- Red and green status LEDs to indicate locked vs. allowed / unlocked status based on current time windows and admin state.
Hardware
The hardware centers around a small ATtiny85 microcontroller on a custom PCB that integrates user input, display, timekeeping, and latch drive circuitry.
Core hardware components:
- Microcontroller: ATtiny85 at 16MHz running the firmware.
- I²C Port Expander: MCP23017, used to scan the 4×4 keypad and drive additional I/O including latch and LEDs.
- Real-Time Clock: PCF85263A, providing calendar time (year, month, day, weekday, hour, minute) for time-window evaluation.
- Display: 128×64 SSD1306 I²C OLED, used in text mode for menu rendering and status.
- Input: 4×4 matrix keypad for PIN entry and menu navigation (digits plus A/B/C/D and */#).
- Latch: Electronic latch driver circuit controlled via GPIO driving a 5V 2A solenoid lock.
The schematic and PCB layout are created in KiCad 9.0, with prototype boards manufactured by JLCPCB and then assembled by hand.
Be sure to set the ATtiny85's fuses so that B.O.D. (brown-out detection) is enabled for 4.3V! Without this, there will be issues with EEPROM read / write stability due to slow rise / fall times of the 5V rail during power on and shutdown caused by the capacitors used in the power circuit.
The following links probably won’t work forever (or even for very long), but are included for completeness: