Software apps and online services
Hand tools and fabrication machines
This project utilizes an IR proximity sensor and an IoT device (Bolt WiFi module, here) to intelligently monitor the state of a locker. It has the following functions:
- detect whether the door is open or closed in real time
- send an SMS when the door is opened
- store the door opening and closing time in a file
- Using an interface, show the current status of the door.
This system can be used for the security of a locker, cupboard or anything where important commodities (such as important documents) are kept. The stored information can be very helpful in investigating theft cases.
The circuit is connected as follows:
Data is be collected via pin 1 of WiFi module.
The IR sensor should be put at a convenient distance from the door. Utmost care should be taken while regarding the position and angle of IR sensor. Nearly 3-4 cm distance should be maintained from the door.
Use double sided tape or hot glue to install the components inside the locker. A cardboard box is recommended for housing or supporting the components.
A file data.csv is used to store the time whenever the locker door is opened or closed. It should be initiated with the following python code:
with open('data.csv','w',newline='') as file:
writer = csv.writer(file)
The python script which fetches data from Bolt device and performs required actions is attached in the code section. Safely study the code to understand what it does.
The 'conf.py' module stores the bolt device login credentials and twilio project data:
To use messaging service, you need to create a project with programmed SMS service on twilio. You need to store Account SID, Authorization token, number generated (FROM_NUM) (while building programmable SMS) into the conf.py module. TO_NUM is the phone number to which message has to be sent.
Bolt device ID can be found on Devices tab in your Bolt Cloud dashboard. API key can be found on API tab.
The python script should be running 24x7. So, it is preferred to run in a remote server (Digital Ocean, for example). If it is to be run on a local computer, it needs to be running all the time.
When the door of the locker is closed, transmitted ray of IR module is reflected by the door's surface and is detected; value 0 is sent. When the door is open, value 1 is sent.
The value sent by IR sensor is received by digital pin 1 on the IoT module.
Every 5 seconds, the value is checked by Bolt API from the python script.
When the door is opened, time is recorded in the file 'data.csv' and an SMS is sent to your phone saying that the door is opened at that time.
When the door is closed, only the time is recorded in the file, no message is sent.
Hence, real time security is provided and a record is also maintained.
Status can be known at any time via the product page. It is described below.
The device interface can easily be accessed on mobile phone using Bolt android app by linking Bolt device to a Bolt product (HTML code attached in Code section). Here is a screenshot:
Or, the Bolt device can directly be accessed from a web page if device ID and API key are known. In the HTML code, just replace the api_key and d_name (lines 26 and 27) with the known api key and device id which can be found at Bolt cloud dashboard.
- Regular power supply is needed. Battery bank should regularly be checked. Higher capacity battery bank is recommended.
- Relies on available WiFi network. Internet connectivity is required all the time.
- csv record file must be kept under high security as it is easily editable.
- csv file should not be opened in Excel or any other application while the monitoring program is running because those applications impose write protection to the file; which leads the monitoring program to crash. Instead, it can be viewed safely by opening in text editors like Sublime Text or VS Code.