Heyo
~if you want to skip straight to the question, go to the pink bit~
Recently I made the tough move to actually secure my passwords and accounts after years of not bothering and using the same "secure" password for everything. In the process of doing so, I downloaded the google Authenticator app for my phone to secure my accounts with 2 factor. If you haven't heard of it before, basically it generates a new random 6 or 8 digit code every 30 seconds, like the bank fobs.
So I had the thought of hey, why not implement this on a safe? Having a pass code that changes every 30 seconds would be cool and secure to keep my cookies nice and safe. So I went out and bought a $20 safe second hand from gumtree and pulled it apart. The circuitry is surprisingly simple, it uses a standard keypad with 7 pins connected to a cheap circuit board which is connected to a solenoid that moves a pin, allowing the safe to be opened, all powered by 4 AA batteries. The circuit board can be scrapped and replaced with an arduino board.
So, to break this project into it's basic components, we need to cover:
- Powering the solenoid - Transistor, done
- receiving keypad input - keypad is compatible with the keypad library
- checking the entered code with a code thats generated - this is the tricky bit
- no external wires or anything leading into the safe - i.e. battery powered, even trickier
The battery power is not a huge issue, as its already been done for long term use, but it's an important factor.
The passcodes need to be TOTP (Timed One Time Passwords) where the time int from 1970 is used with a security key to make the code. This is opposed to OTP which are generated on demand, requiring both devices (phone and safe) to have the passcodes sequenced together which if one gets out of sequence, my cookies are locked away forever.
Thankfully, Lucadentella has already written a library for generating Google Auth TOTP passcodes for his lego house's security system. The only problem is that it requires an accurate time integer, luca unfortunately did this by hard coding the compile time and calculating the time passed since then. This is A. bad practice and B. reliant on arduino's internal clock that can apparently be inaccurate over the long term.
So this is the part that I am stuck at. I need a method of getting the 1970 time integer which doesn't use a wired external source (so not over Ethernet or USB) and is very low powered over the long term (not Wifi?). I know GPS would be a good method, but im not sure it will work inside a metal box, inside a building. There's also more accurate clock modules, but Im clueless when it comes to those...
Any advice would be appreciated.