Safo: a Mini Wifi Vault




Safo is a mini Vault that you can use to store things like your keys, Pen drives etc.
Features:
- 4 DIGIT pin: Each digit of the PIN can be set by the Golden circular dial.
- Reset Your PIN Using WIFI (if you ever forget the old one)
- Once the correct PIN is entered you can choose to manually set a new PIN also.
The first 2 minutes of the video provides a great idea of these features.
It would be an aesthetic addition to your home or desk.
Supplies
.png)


Electronics:
- ESP32 DO IT DEV KIT V1
- SSD1306 128x64 OLED
- Rotary Encoder
- SG90 Servo Motor (with servo horn) Refer to second image to see which servo horn is needed.
- Spare USB Cable
- Some wires
3D Printed Parts (attached):
- safo_mainplate.stl
- safo_bigbox.stl
- safo_dial.stl
Other Tools and parts:
- M3 Screws x2 : 40mm Length
- Soldering Iron
- Hot Glue Gun
- Screwdriver
Software:
- Arduino IDE (New one preferrably).
- Fusion 360: 3D parts designed
Code:
Make the Connections

Refer to the circuit diagram and solder the electronics.
NOTE: You can connect all 5v and GND of all modules commonly to the ESP32 5V and GND
Assemble Electronics




Assemble your electronics in the spaces provided on the safo_mainplate.stl part.
The Servo Motor and Rotary encoder can be easily snapped into the slots.
Hot glue is required for the rotary encoder, ESP32 DO IT DEV KIT board and OLED.
Uploading the Code

Install ARDUINO IDE if you have'nt already.
You can follow the steps below to upload the code.
If you want a better idea of how the IDE works:
- It is pretty straight forward. Here is the documentation to help you set things up:
- https://docs.arduino.cc/software/ide-v2/tutorials/getting-started-ide-v2/
Download and open the code that I have shared in my Github. (Refer Image)
Install ESP32 Board in Arduino IDE


You will need to first install the esp32 board in your Arduino IDE.
Therefore follow these steps to do so:
- Navigate to File -> Preferences
- Add this url in the "Additional Board manager URLs"
- Enter this link: https://dl.espressif.com/dl/package_esp32_index.json
- press OK
- Now go to board manager: You will find it on the left menu.
- search "esp32 by Espressif" you will find the result select on INSTALL (Refer to the second image in this step, it is the second result).
- In my case it is already installed.
Connect ESP32 Board & Select Your Board

- Connect your board to your laptop using a USB B type cable.
- You can see if your board is detected or not in the device manager as shown in my image
- Under Ports(COM & LPT) section, you will observe a name like Silicon Labs 210x etc. It means your Board is dtected properly.
- In case you cannot see anything like that, you will need those drivers.
- You can download the drivers here:
- https://www.silabs.com/developer-tools/usb-to-uart-bridge-vcp-drivers
- Its available for windows and MAC OS
Select the Board in Arduino IDE

- From the previous section, you can observe that my Board is at COM3
- Therefore I need to select COM3 in my Arduino IDE too.
- Then select ESP32 DO IT DEV KIT and you can find it prompted in the dropdown. Select it and Press Ok. (Refer Image).
Libraries Required


Since the esp32 Board has already been installed, the wifi libraries are builtin.
Additionally you will need to download these libraries:
- Adafruit SSD1306 (For the OLED)
- ESP32 Servo
Refer to the images to search them in the Library Manager.
Upload the Code



- Once you have chosen your board press Upload (Arrow Symbol). It is highlighted in the image.
- Now, when it compiles and then starts to upload, you will a connecting ... response in the output.
- Here, you have to press and hold "boot" button on the ESP32 when it starts saying connecting.
- Hold it till it has uploaded.
- Refer to second image to see the compiling stage.
- Refer to third image to see the Uploaded stage.
Test the Working

You can test the code.
Scroll the encoder and see if the digits increment.
Assemble With Container


- Container is the safo_bigbox.stl part
- Use the M3 screws to insert as hinges for the opening and closing mechanism. (Refer image).
- The idea is to pass the two screws through the holes of both the parts on either side.
- Refer to the video for a better view.
Power Using a Spare USB Cable



There is 4 mm hold provided on the back of the safo_bigbox.stl. Insert a spare USB Cable into it, with its ends cut into exposed wires of the positive and negative. Connect these to the 5V and GND of esp32 respectively.
This will power your Safo. You can use a phone adapter, a power bank or your laptop to power this.
Calibrate the Servo Motor



Now, since the code is uploaded and when the device is powered on, the servo motor is in default position of zero.
Before inserting the servo horn, Unlock the device using the PIN. Then the servo will be in unlock position.
As you can observe from the image the little plank is used to lock the box, when the servo moves to locked position.
- So to set it properly, unlock the device using the dial. (You can use Step 13).
- Now position the servo horn as shown in second image.
- Therefore when you lock it, the servo will move to the position as shown in the third image.
- For demonstration I closed it without pushing it till the container.
Insert the Dial


Finally apply some hot glue to the dial and fit it to the metal rod of the encoder as shown in images.
How to Operate Safo

Concept: (The video provides an excellent idea on it)
The PIN for opening the vault is 4 DIGIT
Example the default pin is 1 1 2 2
You can set the default pin in the code.
Go to line number 27 of the code:
So here instead of 1 1 2 2 you can set any other 4 pin code.
Just ensure they are comma separated as shown.
So the first time it displays:
PIN1
DIGITS:
Here's the fun part, the Rotary Encoder or the Dial helps you rotate till the desired number is reached for that particular PIN number. To confirm the number, push the dial (The rotary encoder has a built in switch)
So taking 1 1 2 2 as example:
Rotate dial till 1 is reached.
PIN1:
DIGITS: 1
Next
Rotate dial till 1 is reached.
PIN2
DIGITS: 1
Next
Rotate dial till 2 is reached.
PIN3
DIGITS: 2
Next
Rotate dial till 2 is reached.
PIN4
DIGITS: 2
and once they are all matching with the value, the servo motor opens the lock
Refer to the videos second half to see how the locking mechanism works.
Once Its Open ...


Once the lock is open, you get a Menu as as shown in the image.
If you want to simply lock it back, rotate the Dial to Toggle between the options Lock or Set Pin and choose Lock by pushing the Dial.
To confirm the option, push the dial.
If you want to Set a new Pin:
- Rotate dial to toggle between the two options and choose Set Pin.
- You will get an Interface as shown in the second image.
- It will Show as NEW PIN 1, NEW PIN 2 so on till NEW PIN 4 is set.
- Follow the same steps as in the previous section to set this pin, it is the same.
- Once it has been Set the device will lock automatically. and even when you power on or power off, this new pin will be saved.
NOTE: You can infer from this that you can change the pin manually only when we enter the correct Password.
Wifi Option: If You Forget Your Pin


Now, we know that we can change the pin manually only when we enter the correct Password.
But, What if you forgot the PIN?
For that, we use the WIFI option which you can use to Recover and set a new PIN.
The WIFI network of the device is always on when the device is on.
The video provides the best view on how to set your PIN using WIFI.
Before proceeding with the explanation, observe from Line 40 in the code:
The SSID is the name of the Device Network,
And password is the connection password.
You can change both these variables if required.
Changing the PIN:
- So, using your Smartphone or Laptop, go to your wifi settings.
- You will find a network called "ESP_SAFE_LOCK"
- Press to connect and enter the password: 12345678
- Once it is connected, open a browser and enter the address "192.168.4.1"
- You will get an interface as shown in image.
- In my case I set it as 1 2 3 4.
- Hit save and you will get a page with "PIN Updated!"
And that's it, the device updates this new PIN and you can verify the same.
Thats It! You've Built a Mini Vault!


Hope you liked this project! It would be helpful a ton with a like and let me know your ideas on this.