Time Delay Lock Box

868

1

2

About: Trying to make hobbying my profession

Note from the author: In an effort to get this ready in time for the safe and secure challenge, I have had to make a few compromises to my box, but that doesn't mean you have to! I have left my original ambitions in the text, as inspiration for you to make the best Time Delay Lockbox you can think of.

I was teaching myself to weld and thought I'd make something useful.

The Premise

Were you the kid who ate a single marshmallow now instead of waiting for X minutes and getting two marshmallows?

Imagine you could have put the marshmallow in a box with a timer. Not only would you be certain of the marshmallow's presence and safety, but you would only need to have the instantaneous willpower to box the marshmallow up, instead of the delayed gratification mechanism required to wait out the clock.

Introducing the time delay lockbox!

To overcome your lack of willpower you decide to make such a box. Henceforth the proverbial marshmallow shall be referred to as the payload.

Features

When open, you would be able to:

  1. Set a timer before which you can not open the box
  2. Insert a payload
  3. Close the box

Let's also assume you have no willpower whatsoever and will do anything to get at said payload, therefore we want to make this lockbox ridiculously secure... I mean unhackable and unbreakable (within reason). Therefore, I propose that when closed, you would be able to:

  1. Press a button requesting that the box open

.... that is it. If the box is in a state such that you should be able to gain access, pressing the button would unlock the box. Should the timer not have run out yet, you will just have to wait.

But I'm clever, so I'm sure I can get into the box

In that case, we are going to have to put in some serious measures to prevent you from gaining access.

Regarding form factor we need to aim to remove, minimise or compartmentalise all physical vulnerabilities. Physical vulnerabilities would include:

  • exterior hinges that you could remove the bolt from - therefore mine shan't have exterior hinges. I haven't decided yet, but I think a slide open door is my most viable option.
  • holes into the box, including the one for the button and countdown timer display that you could break out to get at the payload - therefore my screen and exterior button (UI) will be separated from everything else with a steel plate. This is what I mean by compartmentalising vulnerabilities.
  • any box that's too easy to break open - therefore mine shall be made of steel, to compensate for my willpower or lack thereof. I shall also attempt to create my box in such a way as to minimise the possibility that I could force it open using force and leverage.

Physical vulnerabilities could be rendered moot by adding tamper protection mechanisms. Perhaps I'll do something of the sort in my box.

Other vulnerabilities:

We would also need to consider that you may have some epic hacking skills. Therefore once closed you would want to limit your ability to override the system. So apart from that button and screen, there must be no access to the electronics (compartmentalisation).

Could you send a power surge through these exposed components to surge your microcontroller (I'll be using an Arduino Nano)? Perhaps, but will it help you get into the box? debatable/implausible.

I'll be using a solenoid lock for my box, which in its natural state is in a locked position and only opens when enough current at appropriate voltage is sent through. It will need to be inaccessible through the aforementioned physical vulnerabilities.

This solenoid lock poses a theoretical override mechanism... It is the only vulnerability I have been able to identify thus far.

Solenoids work by using an induced electromagnetic field in a coil to push/pull a rod. So could I create a coil, placing it alongside the box and induce a current (as seen in a common transformer) in the coil of the solenoid, that would cause it to unlock?! I'm not sure. My google searches have turned up no results to indicate that this is anything other than theoretical. Regardless, precautions will be taken to limit the viability of such a hack, by distancing and or insulating the solenoid from the case exterior.

Backup power is obviously a must, so you don't just reset it. For my box, I'll be limiting vulnerabilities once more by making battery power contained within the box, the only power source. To ensure the power source doesn't die out on me before the clock runs down, I'll be using a large battery source.

If you come up with a hack for your box, patch that vulnerability.


Features could pose vulnerabilities!

I wanted to add USB ports for charging devices and stuff, but this could introduce further vulnerabilities. Also, it extends beyond the scope of this Instructables, so let's begin.

Step 1: Gathering Materials and Tools

The box

Mine shall be made of square steel plates. They came as 150mm x 150mm and are 3mm thick. For a single wall structure you would need at least 6 obviously. Compartmentalising would require more material.

For additional structural integrity, I'll be creating a frame for them from 40mm angle iron, mine looks to be slightly thicker than the plating. I didn't manage to complete the frame, However the box is pretty bloody sturdy as it is.

You may adapt this to your needs. If you think a wooden box will do, go for it. If you think you need something stronger, go for it. I'm sure after building this, I'll be too heavily invested to attempt to destroy my steel box just to get at the payload.

The electronics

I'm using this Arduino Nano, but you may control this using any Arduino or even just do something like this using just an ATmega328 micro controller.

A display of sorts. I was using a straight up 7 segment LED display, but there are too many wires for my liking, so I'll be picking up something like this tomorrow, which has onboard circuitry, requires just 4 cables, and has 4 digits. You can use whatever you wish though, even a single LED could provide the information by blinking X times to represent X hours.

A few buttons, and or other inputs. I'll be using a couple buttons along side a switch like this to set the state (Set timer/Unlockable/Armed), a potentiometer (*Edit - I've chosen a rotary encoder rather, but you could use a potentiometer) to select the digit value, and a button suitable for attaching to the case - note that I'd prefer the lock nut thing to be on the inside so I don't attempt any shenanigans by simply screwing loose the button.

A locking mechanism. I'm using a 12v Solenoid Lock.

An N-type MOSFET to act as a switch to supply the high current power to the solenoid, without running it through the microcontroller. You could also use a relay. Anything that will act as a switch when the microcontroller tells the solenoid to activate.

Some diodes won't hurt either to protect your micro controller from inevitable reverse current or something (a new concept to me, but I've burned out a couple pins on a couple Arduinos now, and it seems it may have been avoided with appropriately placed diodes)

The power supply etc.

Many hours I have deliberated on this. I considered using a small battery power supply to save on weight and integrating some capacitors to store enough current/voltage for the solenoid. This is a perfectly acceptable design solution.

However, my current design utilises a capable battery instead.

I've chosen a 12v 1.4Ah lead acid battery because it has a large capacity (Ah), can deliver the necessary current to power my solenoid and is rechargeable. It's also pretty cheap, and seeing as it's main drawback is weight, I think I decided this wasn't a consideration when I decided to make the box out of steel. I will be using voltage regulators with this to ensure I don't supply too much voltage to any components. Voltage regulators are less power efficient and you should rather use a step down transformer. I didn't manage to procure one in time to submit this Instructables for the Safe and Secure challenge, but I recommend you do. -- and with just a few hours left in the competition, my Arduino just went pop and appears dead, so really.... get a dc dc step down.

Tools etc.

Should your box be made of metal:

  • Welding machine
  • SAFETY EQUIPMENT! Gloves, welding mask etc. Please view welding instructions elsewhere if you aren't sure how and what.
  • Set square type magnetic clamp and or other square type clamp/jig (I've used both so far)
  • Angle grinder
  • Cutting disc for angle grinder
  • Sanding disc to clean up welding

Solder iron (unless you want to just use breadboards and jumper cables)

Multimeter (for testing and troubleshooting)

An LED (completely optional for testing. I use it as I code to test that signals are being sent when they should be)

All set? Let's do this!

Step 2: Designing and Building YOUR Box

I'm kinda designing on the fly while I build this project as I haven't gathered all my components yet. As it stands, I have an open box made of the steel plating, that is (W)156mm x (L)156 mm x (D)150mm. Angle iron makes the one plate into a lid that can slip over the rest of the box.

---The following evening---

Oh progress is so sweet. Decided it might look neater and would be mechanically stronger if I could create a mechanism like a deadbolt, but using the steel plate to lock the lid and the box together. Then the solenoid would only hold onto the steel plate. The solenoid could then act as a pin in a bolt, making the weakest link my steel again instead of the flimsy solenoid. It took some serious visualising, so I'll demonstrate what I mean in pictures.

---The night before the Safe and Secure challenge cut off date---

In an effort to get the project completed in time, I've redesigned my concept. The design is simple, and I'm sure sturdy enough. The lid has a bit of angle iron welded to it, to create a lip that can catch on the solenoid to lock, which would be mounted within the box. Simple elegant solution, as seen in the video.

Step 3: Electronics and Circuitry

Breadboard everything until you know your prototype will work

OR

If electronics aren't your thing, just follow my final design exactly (or make your breadboard version permanent, and run my code (following step) and it should work.

Minimum viable product would have a button to start the timer and a potentiometer to set the time. My very first version (not shown here) had a single digit display (that uses so many cables), 1 potentiometer to adjust the clock and one push button to start it. I didn't have a button when first building this so it was substituted with a cable that I'd plug in as if I were pressing a button. I'd also substituted the solenoid with an LED for this test phase, as I didn't have an adequate power supply on hand.


Final Prototype

I have:

  • 3 position switch to control the state of the box between setting the clock, neutral, and arming the clock. (more on this after the code)
  • A push button to attempt to unlock the box
  • A 4 digit 7 segment display (TM1637)
  • A N type Mosfet to act as a switch to the solenoid
  • A solenoid
  • A diode to prevent reverse current when solenoid deactivates
  • A gate motor battery
  • A voltage regulator (mine is a variable one, because it's what I have available, but use anything to ensure you don't provide over 12v to your Arduino)
  • An Arduino Nano as the micro controller
  • Veroboard to tie it all together after prototyping

I've spent the night making a schematic for the circuit design, trying to keep it as neat as possible. Check it out on Fritzing or in the images.

I've also included pictures of my final prototype - I'm running the Arduino Nano off my Mac's USB port in the breadboard prototype.

Close ups of individual sections and labels, along with matching diagrams are all in the images and should help you get it right. Because I don't have a camera of my own (I shorted my phone's camera during a hasty screen replacement) and had to borrow a friends phone while he slept, I must apologise for the not fantastic photos. Together with the diagrams, I'm sure you'll work it out.

NB: In the Fritzing schematic I have added the DC/DC step down converter because I plan on getting one by the time I complete this project. I didn't in the end though, so my final is using a variable voltage regulator. It isn't in the pictures. As I said, my prototype uses USB to power the Arduino.

Reducing the breadboard prototype to something more permanent

This has proven much more challenging than I anticipated. If I have any tips for you, it is that you should ensure your solder iron tip is clean and tinned, and that you should use not too much solder. Also, perhaps make your design less compact than mine, as mine required bridging between rails and more cutting rails than I would do next time. Save that compact design for a PCB if you want to have one made.

Remember I wanted to compartmentalise parts of the electronics as additional security?

UI Exterior - Display and unlock button

Interior - Arduino, Power, Rotary encoder, 3 position switch

Locking Mechanism - Solenoid

I designed a circuit for my veroboard, the new layout means I've assigned components to different pins on the Arduino, so take care to ensure your code and your setup are aligned.

I blew a pin so I had to reassign that variable in the code. If something isn't working right, check if the pin works using the Blink code, or blink on button press if testing input. If the pin is busted, you can attach the component to another working pin and use that in the code. Just remember not to use pin 13 as it controls the LED on the board and will send a HIGH signal through pin 13 when the device boots up.

The sad tale of the Arduino that was killed

Beware of leaving your circuit plugged in! Learn from my mistake!

Just hours before the deadline to be entered into the Safe and Secure challenge, I shorted and killed my Arduino that was soldered to the veroboard, while it rested atop the 12V battery. Hence the "working/final version" that you see here is one I had to quickly make up for now, as removing and replacing the dead Arduino was not an option with the time I had left. Also, really, make sure all your rails are only connected where they should be. I've left a picture with lines drawn to show you how I made my veroboard prototype, but I recommend you do one that is spaced out better and resembles the breadboard version rather, as my design proved time consuming, complicated to visualise, and finicky. I'd even go as far as adding tape to the entire circuitry, on the bottom, to insulate it once you have your veroboard prototype working.

Step 4: Code

The code is displayed below. I've commented it thoroughly to explain what's going on, but basically I created a state machine to swap between 3 states, SET, BOX_UNLOCKED, and COUNTING_DOWN. The display blinks the time set when entering the countdown mode, says SEt- when entering the set mode and OPEn when opening the lock.

If it is in the state COUNTING_DOWN, and you try to unlock it, the clock will display the time left. Once the clock counts down to 00:00, it will blink "00:00" and the state machine will swap to BOX_UNLOCKED.

When in BOX_UNLOCKED state, if you press the button it will display OPEn and activate the solenoid for 2 seconds. When the state switch is in neutral, or set positions it will always be in BOX_UNLOCKED state.

The code is attached in this step, but possibly more up to date versions are available on GitHub: https://github.com/SirLucian/TimeDelayLockbox

There are still features I wish to add, and may have added by the time you read this, so check out the GitHub.

/* The Time Delay Lockbox V1.11 - By Lucian Blankevoort www.sirlucian.me
* * For more instructions on building out such a box, please see the instructables for Time Delay Lockbox under my Instructables profile https://www.instructables.com/member/LucianB10/ * All materials needed, schematics etc are detailed there * * You will require the TM1637Display and the Encoder libraries * * Author: Lucian BLankevoort * License: MIT License (https://opensource.org/licenses/MIT) * * V1.11 Serial update on switching case & display indication of state, rotary encoder now goes up by 10min increments when setting clock, Pin change because of failed * V1.1 - New pinout to match circuit layout on protoboard * V1.01 - Now using minutes and hours instead of seconds, and includes the colon * * * ToDo: * Low power mode * Saving clock to eeprom so power off and on doesnt reset clock * Push Rotary button to reset clock * */ //Libraries to include #include #include #include

//State machine #define COUNTING_DOWN 0 #define SET_CLOCK 1 #define BOX_UNLOCKED 2 uint8_t device_state; uint8_t old_state;

// Switch pins for your setting your box's state. Put the middle pin on the negative rail #define SET 7 #define ARM 11

// Display module connection pins (Digital Pins) #define CLK 8 #define DIO 9

//The word "OPEn" in something the display can understand... for that special moment when you may finally open your box const uint8_t OPEN[] = { SEG_A | SEG_B | SEG_C | SEG_D | SEG_E | SEG_F, // O SEG_A | SEG_B | SEG_E | SEG_F | SEG_G, // P SEG_A | SEG_D | SEG_E | SEG_F | SEG_G, // E SEG_C | SEG_E | SEG_G // n };

const uint8_t SETCLOCK[] = { SEG_A | SEG_F | SEG_G | SEG_C | SEG_D, // S SEG_A | SEG_D | SEG_E | SEG_F | SEG_G, // E SEG_F | SEG_G | SEG_E | SEG_D, // t SEG_G // - };

//Rotary encoder Push button (not used currently in this version), A and B #define ROT_BTN 3 #define ROTA 4 #define ROTB 2

//Lock mechanism #define SOLENOID 5 #define UNLOCK_BTN 10

// Initialise the display TM1637Display display(CLK, DIO);

// Initialise the rotary encoder Encoder Rotary(ROTA, ROTB);

// Clock tracking long seconds = 0; uint8_t hours; uint8_t minutes;

// Rotary encoder long posRotary = -999; long newPosRotary; bool setHours = true;

// Display Variables //uint8_t displayValue;

// This function unlocks the box when/if you can void unlockBox(){ Serial.println("Unlocking Box"); display.setSegments(OPEN); digitalWrite(SOLENOID, HIGH); delay(2000); digitalWrite(SOLENOID, LOW); display.clear(); }

// Function to be called when beginning the countdown. Not used yet. supposed to blink out the value a few times void beginCountdown(){ display.setBrightness(7, true); displayValue(); delay(500); display.clear(); delay(500); displayValue(); delay(500); display.clear(); delay(500); }

void displayValue(){ secsToHourMin(seconds); // This displays the minutes in the last two places display.showNumberDecEx(minutes, 0, true, 2, 2); // Display the hours in the first two places, with colon display.showNumberDecEx(hours, 64, true, 2, 0); }

// Function to convert seconds into hours and minutes for the tube display void secsToHourMin(long sec){ hours = sec / 3600; sec %= 3600; minutes = sec / 60; } //and from hours and minutes to seconds long HHMMtoSec (uint8_t h, uint8_t m) { m = h*60 + m; seconds = m*60; return seconds; }

// Start up Arduino void setup() { Serial.begin(9600); pinMode(SET, INPUT_PULLUP); pinMode(ARM, INPUT_PULLUP); pinMode(ROT_BTN, INPUT_PULLUP); pinMode(UNLOCK_BTN, INPUT_PULLUP); pinMode(SOLENOID, OUTPUT); digitalWrite(SOLENOID, LOW);

display.setBrightness(0x0f); // Clear display of any text display.clear(); }

void loop() { // If you press the unlock button while the device isn't armed, the solenoid will activate. This means if you close the box while setting it, or if you put the switch in the neutral position, it will still unlock if (digitalRead(UNLOCK_BTN) == LOW && device_state != COUNTING_DOWN) { unlockBox(); }

// If the switch is in the set position, you activate the state in which you can set the clock if (digitalRead(SET) == LOW){ device_state = SET_CLOCK; } // If the switch is set to the ARM position, you start the countdown. Once you close the box, you will not be able to unlock it until the countdown timer reaches zero. else if (digitalRead(ARM) == LOW && seconds != 0){ device_state = COUNTING_DOWN; } // When in the switch is in the neutral position, the box is naturally unlockable else { device_state = BOX_UNLOCKED; } // If state has changed if (old_state != device_state) { if (device_state == 0) beginCountdown(); if (device_state == 1) display.setSegments(SETCLOCK); old_state = device_state; Serial.println("State changed to: "+ device_state); delay(1000); display.clear(); }

//uint8_t displayValue = seconds; secsToHourMin(seconds); //Switch to control states switch (device_state) { // State 0 - Counting down. When device is armed the clock starts to count down case COUNTING_DOWN: display.clear(); if (seconds>0){ seconds--; delay(1000); Serial.println(seconds); } // If device is not yet ready to unlock, it will display the current time left on the tube display if (digitalRead(UNLOCK_BTN) == LOW && seconds !=0) { displayValue(); delay(1000); seconds--; } // If the countdown timer reaches zero, it will switch to the unlockable state if (seconds == 0) { display.showNumberDecEx(0, 64, true); delay(1000); display.clear(); Serial.println("Box unlockable now"); device_state = BOX_UNLOCKED; break; } Serial.print("Seconds: "); Serial.println(seconds); break;

// State 1 - Box Unlocked. In this state, the solenoid will be activated when you press the unlock button. case BOX_UNLOCKED: display.clear(); break;

// State 2 - Setting the clock. When the switch is set to this position, you may rotate the rotary encoder to adjust the duration that the box will be in countdown mode for. // Pressing the rotary encoder push button swaps between setting hours and minutes case SET_CLOCK: newPosRotary = Rotary.read(); if (newPosRotary != posRotary) { posRotary = newPosRotary*150; seconds = posRotary; }

//Reset clock to Zero //if (digitalRead(ROT_BTN) == LOW) seconds = 0;

// The display will show the time set while you set it displayValue(); Serial.print("seconds = "); Serial.println(seconds); /*case SET_CLOCK: long newPosRotary = Rotary.read(); if (setHours){ if (newPosRotary != posRotary) { posRotary = newPosRotary/4; displayHours = posRotary % 99; display.showNumberDecEx(displayHours, true, 2, 2); if (ROT_BTN == LOW) setHours = false; Serial.println("Hours: "); Serial.println(displayHours); } } else { if (newPosRotary != posRotary) { posRotary = newPosRotary*(2.5); displayMinutes = posRotary % 59; display.showNumberDecEx(displayMinutes); if (ROT_BTN == LOW) setHours = true; Serial.println("Mins: "); Serial.println(displayMinutes); } } seconds = HHMMtoSec(displayHours, displayMinutes); displayValue = secsToHourMin(seconds); display.showNumberDecEx(displayValue, 64, true);*/ break; default: break; }

}

Step 5: Putting It All Together

Got your box?

Electronics set up?

Code functioning as it should?

You are ready to stick it all together and have your very own Time Delay Lockbox!

Unfortunately I did not manage to finish my box in time to submit for the Safe and Secure challenge, but I will complete it fully soon and update this Instructables thusly.

Step 6: Form Follows Function. the Finishing Touches

Now that your box is complete, make it truly yours by decorating it!

As I'm sure you have noticed, I made a custom engraved lid using a Dremel with some diamond engrave tips I picked up from my local hardware store. Have any other cool ideas to personalise your box? Do it and post your results for the world to admire.

Did you have some awesome design implementation for your locking mechanism? I want to see it!

Did you manage to hack into your box somehow? How did you patch these vulnerabilities?

And if you are really brave, put something special inside for the smartest person you know, and see if they can hack into your box. Leave it with them for 99 hours and 59 minutes. Or if you are really sure of yourself, adjust the code to be in days and hours and leave it with them for a couple weeks to see if they can figure out a way in!

Share

    Recommendations

    • Epilog X Contest

      Epilog X Contest
    • Organization Contest

      Organization Contest
    • Faux-Real Contest

      Faux-Real Contest

    2 Discussions

    0
    None
    jessyratfink

    14 days ago

    Really well done! Love all the thought that went into making sure you limited the ways to get in. :)

    1 reply
    0
    None
    LucianB10jessyratfink

    Reply 11 days ago

    Thank you :) I was thinking of my friend DD and how would I DD proof the box. >__