Table of Contents

Safe Deposit Box

Diana-Alexandra Predescu - ACES 2021

Project description

The purpose of this project is to simulate a safe deposit box that can be remotely controlled through a Web server. This application can easily be integrated into the concept of smart house. For this project I will only focus on the remotely controlled part.

In this project, the box can only be opened/closed with buttons from a Web server, after connecting to Wi-fi. With the help of two sensors, the application can figure out when something isn’t right and change the status of the box in the Web server. If the door is broken without opening it from the Web page, or it detects accelerated movement the system alerts the user with a status message in the Web server. All the above was possible by interfacing ESP 32 microcontroller to the external modules.

Hardware description

The modules used to achieve the functionality mentioned above are:

The electrical schematic of the circuit and the breadboard implementation can be found below:

Software description

The application was developed using Arduino IDE. To facilitate the software development the following libraries were used:

Since we will display constantly the sensors values in the Web page, I chose to create the HTML page using AJAX (Asynchronous JavaScript and XML) which allows me to update only the values coming from the sensors in the background. This eliminates the flickering when refreshing the whole Web page.

The Arduino application is structured into 2 parts. The setup part where all the initializations are made, a code that is executed only once at the beginning of the application, and the loop, which will listen to the client’s requests and will act accordingly to the handlers.

  1. setup(): the following points are approached
    • Wi-Fi configuration and connection.
    • Calibration of the accelerometer – we measure 16 times and do the average value to find the offset for every axis (initial values for the start position). From the Z-axis we substract the sensitivity based on the sensor datasheet.
    • Servo motor configuration – frequency, minimum and maximum position based on the datasheet.
    • Attaching an interrupt on the pin coming from the optic sensor, in “RISING” mode. Every time the obstacle is removed from the LED light front, simulating the door opening, the signal goes from 0 to 1 and the interrupt is called, verifying if the door was opened as well. If yes, the box status is ok. If the optic sensor is triggered and the door was not opened previously, the status is changed to “Check the box” and the user must reset the system.
    • Attaching Handlers on the HTTP_GET requests from Web page. We have 4 handlers corresponding to Web page creation, get accelerometer values, close/open door, get the system status.
  2. loop(): in this function we only listen to the client side and call the corresponding handlers.
    • After connecting to the IP address, the HTML page is created. Every 2 second, the accelerometer does a measurement and answers to the HTTP request with the corresponding values, values which will be updated in the box. Moreover, at every measurement, we check the measured value with the initial one, if we detect a rate of velocity change beyond the interval set, we alert the user by updating the system status. The status is updated every 2 seconds in the page. Furthermore, the application offers 3 buttons. One for “Open” door, which will load the appropriate value onto the control pin of the servomotor (from 0 to 180 degree), one for “Close” door which does the same as the previous only from 180 to 0 degree, and one for “Reset” that will reset the system. This can be used for further development of blocking the safe box if it is broken into.
    • The system status that needs to alert the user can be updated from 2 use cases:
      1. The optic sensor is triggered without opening the door;
      2. When the accelerometer detects a bigger change in the velocity;

Below is the flow diagram of the system.

Issues and solutions

Issues found and possible solutions:

Conclusions

The project can be considered a starting point or at least a part of the “Smart House” and “Smart appliances” concept, concept which is supposed to ease the user life and give a feeling of being safe and being in control. It also gives a brief view into how a MCU can interact with different external modules. The idea behind the project was to integrate into the IoT world that nowadays is everywhere, something that can benefit a wide interval of people, without limit of age, something that can be used on a daily basis.

References

Materials: https://gitlab.com/dianaalexandra5/safe-deposit-box