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:

  • ESP-WROOM-32 Board: is the MCU which controls the system, handles the web page and ensures the interface with the external modules. The board was programmed using Arduino IDE;

  • FXLN8371 Accelerometer: the module measures the rate of change of the velocity of an object in G-forces(g). The FXLN8371Q offers an analog interface, which measures acceleration from the variation between ground and power supply voltage. The voltage level from the output pins can be converted with an ADC to a binary value to be interpreted by the processor. In order to offer accuracy, the accelerometer had to be calibrated first. It is connected to the 3.3V power supply coming from MCU, XOUT to GPIO34, YOUT to GPIO35 and ZOUT to GPIO32.

  • Optic sensor: a sensor based on an infrared light from a LED which illuminates a phototransistor. If an object is placed between the LED and the phototransistor, the LED light turns off. This will check if the door is closed. The module is powered from 5V and the signal pin is connected to GPIO19.

  • SG90 servo motor: A simple servo which simulates when the door is opened/closed, making it rotate from 0° to 180° and back. The servo is connected to 5V and the PWM controlling signal to GPIO18.

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:

  • WiFi.h and WiFiClient.h for Wi-Fi connection. Now, the Wi-Fi network credentials are hardcoded into the application. Using these libraries, the MCU can connect to the network. We save the IP assigned for the Web Client application.
  • ESPAsyncWebServer.h to facilitate the web server handlers based on HTTP requests.
  • ESP32Servo.h, offering methods to control the servo motor.

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:

  • Updating sensor values without the user needed to refresh the page manually → solved by using AJAX based server.
  • Sometimes when the servo motor is working the accelerometer gives inaccurate values → Not solved. Assuming it might be linked to the power consumption. One possible option might be to connect the servo motor to external power supply.
  • Not a secure environment. The application hardcodes the network credentials. → Not solved

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

iothings/proiecte/2021/safedepositbox.txt · Last modified: 2022/01/27 21:47 by diana.predescu
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0