B-Safe, the Portable Safe




Introduction: B-Safe, the Portable Safe

About: My name is Bastiaan. I am 44 years old and one of my hobby's is designing and building stuff.

*** Sept 4th 2019 : I uploaded a new 3D file of the box itself. It seemed that my lock was 10 mm too high for a good close ***

The problem

Imagine this:

You wake up one morning and the weather is real good. You want to go to the beach.
Because you don't live too close to the beach, you take your car. To pay for the parking
at the beach, you use your phone.

This means that you go to the beach carrying (at least) the following items:

  • Car keys
  • Drivers License
  • Phone
  • Towel

What do you do with these items when you want to go for a swim?
You leave them unattended at your towel? Hmmm. This problem needs a solution ...

The solution

For the problem as described above, I created a portable safe. The B-Safe, where
the B stands for beach or for my name, Bastiaan. It's pronounced as Be Safe.

How does it work?

Each B-Safe has an own personal pincode programmed into it. When the B-Safe is off,
it's open. You put your important stuff, like keys, license and phone, inside the box,
flip the switch to turn it on, close and lock it and enter your personal pin.
The B-Safe is now armed and locked.

Whenever someone takes your box, one of the LED's will lit up for a few seconds.
If, after these few seconds, there is still movement, a loud alarm will sound. This will not
stop until you enter the right pincode again. But if you do enter the right pincode within
the moment of movement, the B-Safe disarms.

It is not recommended that you use the B-Safe on an empty beach. The idea is that when
someone walks or runs over the beach with a very noisy box, bystanders stop him / her.

To create this yourself, you only need to follow steps 3, 4, 5 and 6


Used supplies:

  • Arduino Leonardo (without pins)
  • Headerpins male 40 pins metal 90 degrees
  • Multiple jumpercables female/female
  • Switch Rocker Snap-in On/off rectangular black
  • Wire 1x0,2mm2 multicore flexible core black
  • Wire 1x0,2mm2 multicore flexible core red
  • Wire 1x0,2mm2 multicore flexible core yellow
  • a little piece of heat shrink tubes
  • LED 5mm red
  • LED 5mm green
  • speaker 3-24V
  • 9V battery
  • 9V battery connector
  • Resistor 120 Ohm 1/4w 5%
  • Resistor 100 Ohm 1/4w 5%
  • 3D printed box
  • 4x4 Keyboard
  • small piece of PCB board
  • small lock (I took one out of a safe box from Action)
  • 3-axis accelerometer MPU6050
  • some used screws from small "left-over" electronics like television remotes
  • several M3 screws
  • a little glue for the LED's
  • a lot of beer

Step 1: Prototype and Testing

For my prototype, I used a breadbord and some "plug-wires"
With everything connected, I started to create the Arduino code and tested, tested and tested it.
Connect everything different, re-write the code and tested it again.

Right until I was satisfactory and everything worked exactly the way I wanted it to.

Step 2: Wiring Schematics

The wiring is quite simple. Just use the schematics to wire everything.
Just try to use as short cables as possible, so everything will fit in the lid perfectly.

Step 3: Soldering

I measure all the wires so that they are not too long, cut them and strip the end. Then, I connect all the wires to the parts using a soldering iron. I also use heat shrink tubes. Make sure you put them (loose) on the cable before connecting the cable to a part.

The parts that I soldered are:

  • 90 degree angle connector pins on Arduino
  • 90 degree angle connector pins on keypad
  • wire to LED's
  • resistors on PCB
  • wire from speaker to PCB
  • power button

Step 4: 3D Print All Parts

I designed the whole box and everyhing with it in Autodesk Fusion 360. This took me a very long time because I wanted everything to be perfectly right how I wanted it. My first design had the Arduino on the bottom, but this final design has everything inside the lid. Inside the lid there are pre-made holes for securing everyhing with (M3) screws.

To print the parts, I use a Tronxy P802M (similar to a Prusa i3) with a bed of 200 x 200 x 220. I sliced the STL's using Ultimaker Cura. I made an export of the settings I used for Cura. You can download my Cura profile here.

I also uploaded my STL's here. There are four, the box itself, the lid, the lid cover and the knob on the lid.

Be aware: the box itself took me more than 24 hours to print !

Step 5: Load the Code

Because I'm still deciding whether or not to take the B-Safe into real production, I decided to put only a pre-compiled .hex file here. This .hex file is fully working and ready to upload into your Arduino.

The pre-compiled .hex file has a pincode of "9503"

If you'd like a customized pincode, drop me a line and I will send you a new .hex file with your own personal code.

Step 6: Assembling All the Parts

Assembling is, because of the design, quite easy. The keypad and the speaker fit perfectly in the lid. I uses some old (very tiny) screws from an old remote to secure the keypad to the lid.

The Arduino Leonardo and the piece of PCB are secured with M3 screws.

You can use a piece of filament (3D print wire) to secure the lid to the box itself. The holes in the lid and the box are 2 millimeter and the filament is 1.75 millimeter, so this fits perfectly!

The battery goes without securing it in the lid. Because of the lid cover and the immersed square in the lid, the battery won't move when putting the lid-cover. The same goes for the speaker and the on/off button. These also go unsecured in the lid.

The only thing glued are the LED's, but this is just a precaution to avoid them coming out when you push them on the outside.

For wiring the Arduino, the following pins are used:

  • Arduino digital 0 to 7 ; Keypad 1 to 8
  • Arduino digital 8 ; red LED
  • Arduino digital 9 ; green LED
  • Arduino digital 12 ; speaker
  • Arduino SCL ; MPU5060 SCL
  • Arduino SDA ; MPU5060 SDA
  • Arduino 5V ; MPU5060 VCC
  • Arduino GND ; GND on small PCB
  • Arduino GND ; 9V battery
  • Arduino VIN ; 9V battery

The reason I didn't use an electronic lock is because I couldn't find an electronic lock small and strong enough to make this design work. This is on my list of "changes for improvements" (step 8)

Step 7: Go to the Beach

The box is now finished and assembled.
Now it's time to go to the beach!

Small instructions on how it works:

  1. Open the (unlocked) box and put your important stuff inside
  2. Close, lock the box and take the key
  3. Put the box on the location where you want it to be
  4. Press the asterix ( * ) button - The box is now armed
  5. Go swim
  6. Take the box and enter your pin
    1. If you press the wrong password, you can use the pound ( # ) key to start over
  7. Unlock the box using your key

That's it! Have fun !!

Step 8: Changes for Improvement

Like every project, a good project is never truly finished. (Although I think it's a very good project :P) That's why I'm writing, (while I make this project), a list of improvement below:

  • better Arduino code
  • change the lock to an electronic lock instead of a mechanical lock
  • ability to change pincode manual (with Arduino code and EEPROM)
  • make a battery lid to replace battery more easy
  • make the speaker work on more than 5V using a "TIP120" transistor
  • replace the Arduino Leonardo for an Arduino Nano

If you have more improvements to add, please let me know!

Sensors Contest

Runner Up in the
Sensors Contest

Be the First to Share


    • For the Home Contest

      For the Home Contest
    • Make It Bridge

      Make It Bridge
    • Game Design: Student Design Challenge

      Game Design: Student Design Challenge


    Thank you very much thanks to you i managed to pass the informatics course doing a project similar to yours i managed to have a 17 from 0 to 20 in the evaluation of the project sorry i didn't come to thank you earlier but thanks and for the help you gave me when i was not able to see the code and you put it on the site. Thanks.

    Reply 1 year ago

    Congratulations! And you are very welcome.
    I'm glad I could help you a little !


    Could you send me the code in arduino? Please, I can't open it in this format. I'm a student and I'm developing your project. If I can't, I will fail the course.


    Reply 2 years ago

    Your welcome for putting the source code....


    Reply 2 years ago


    I added the code to this page.
    Good luck,



    Question 3 years ago on Step 5

    How do I upload the code to my Arduino? It's in hex form and I have no clue as to how to open it or upload it :(


    Answer 3 years ago

    I sent you a message ;-)


    Question 3 years ago

    Can I please get the dimensions of the box? My 3D printer can only print 140x140x140mm objects.
    The file you shared are STL files and I am not able to get the sizes from it. It would help me if you could either shared the .f3d, .cad files or the dimensions of the box.

    Thanks in advance.


    3 years ago

    I love this project and I think you should take it further. Your suggestions for improvement are all good too. In production perhaps consider an aluminium box (lighter than steel and yet difficult to break into without tools) and a very very loud alarm. Well done.


    3 years ago

    Bastiaan, I think this is great. Just a thought I had, maybe add a fingerprint scanner just for ease of use for you, and make it out of steel because plastic is easily broken obviously. Still, great job man


    Reply 3 years ago

    Thanks. I don't quite know how to make this of steel. But because there are more people telling me this, I will look into it. A fingerprint scanner is also a good idea! Thanks for your feedback!


    3 years ago

    Heel leuk project. Ik heb ook mijn "3D-print alles wat je kan bedenken" periode gehad, maar ik denk dat ik voor een kluis misschien toch iets sterkers zou nemen. (ik zit momenteel in mijn "lasercut alles wat je kan bedenken" periode, dus waarschijnlijk zou ik voor Lexan gaan :)


    Reply 3 years ago

    See my previous reply (to igggy17)
    I personally have no experience with laser cut (yet) but maybe in the future I will look into it. ;-)


    Reply 3 years ago

    Whenever you are in "De Hoekse Waard" you are welcome in my Makerspace to try mine :)


    3 years ago

    If you do it of steel, and fix it


    Reply 3 years ago

    Thank you for your reply. This safe is actually not ment to be strong. I am well assured that this safe can be opened very easy. It's more that if someone picks it up or move it, the alarm will notify people around you. But making it of steel is a really good idea.


    Question 3 years ago

    it is a really nice idea but i was trying to make this but the code is just not working


    Answer 3 years ago

    Hi, thank you for this question. Can you tell me exactly what does of doesn't work?


    3 years ago

    Excellent idea! Please post if you go into production. I would buy one.