Back to Parent

Problem Statement

My sister is forgetful, paranoid, and extremely busy. She is often rushed and scatterbrained when leaving for work in the morning. It is common for her to worry that she forgot to lock her front door. This will bug her throughout the day, reducing her ability to concentrate.

Goal

The primary aim of this project is to allay her fears: to provide her with a way to check if she locked the front door and make sure no one else has unlocked her door since her leaving. Furthermore, some mechanism to help prevent her from forgetting to lock the door is key.

Requirements are as follows:

- A subtle visual indication of whether the door is locked or not. This will help remind her to lock it and the change in indicator will help her remember that she did it.

- Real-time tracking of the state of the deadbolt from her phone.

- A log of every time the deadbolt is locked and unlocked, available from her phone.

Process

I didn't have a hall effect sensor to work with at first, so I used a button to simulate the binary signal the sensor would provide.

I first worked on writing a decent function to communicate with the LED. I wanted something simple and reusable, so I modified an existing function to take a clean 6 digit hex value instead of a delimited string of binary values.

Next I wrote a separate function for monitoring the button. I set it up so when the button was pressed, the LED would change. I quickly noticed a problem -- the code was acting on the state of the button, not whether the button's state had changed. That is, holding the button down would send a flurry of continuous calls to the LED function. In response, I modified the function to only act on specific changes in state, rather than the state itself.

When a hall effect sensor was obtained, I replaced the button with the sensor and modified my code where relevant.

The website was written after the device was built.

Lastly, device code was optimized -- pulled it down from 100 lines to about 50!

Outcome

The solution contains the following components:

- A Photon connected to a hall effect sensor and an RGB LED.

- A portable phone charger battery pack as a power source.

- A magnet attached to the manual deadbolt handle.

- A hosted website.

The Photon senses whether the lock is engaged or not by detecting the position of the lock handle using the hall effect sensor. When the lock is enabled, the LED glows red. When the lock is disabled, the LED glows green. In addition to being visible while inside the apartment, the LED is also visible from outside the door via the peephole. This provides visual feedback to help cue memory.

When a state change in the hall effect sensor is detected, a cloud variable is updated and a webhook calling a PHP script on my servers is called. This script records the lock's state change in a log file.

The website displays the current status of the lock as well as the log file of events. This uses a recurring AJAX call to keep the information updated in real time -- no browser refresh needed. The call to Particle's servers uses a PHP proxy so that tolkens are not exposed in client-side code.

Reflection

This project was a fun introduction to the Arduino language and connecting physical sensors to web services. I gained experience enabling communication between a Photon, web server PHP, and client-side Javascript.

In future versions, I would work on the following:

- Improve the device to make it less intrusive and more durable: enclosure, mounting, sensors, status LED. Right now, it's fairly fragile and the door opening and closing carries enough force to knock the circuit loose. Additionally, it is an eyesore -- an enclosure would help with this.

- Improved battery life. The current setup is not optimized to reduce power consumption. Furthermore, a better battery pack could be installed.

- Add a sensor for detecting when the door itself is opened and closed, which would allow knowing if anyone has actually entered the apartment in the event that it was left unlocked.

- More advanced and meaningful data presentation online, rather than just a stream of events.

- Push notifications.

- Better security for the online information.


Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0