Many of us have experienced the situations that when we come home tired, we usually throw the key randomly somewhere without thinking, which leads to fishing around for keys by the time we need to go out. Or we head out in a rush to catch a bus, keep an appointment, meet some friends, and carelessly leave the key home, then become vexed soon afterwards. At that time, we would wish if someone had reminded us of taking the key before closing the door. So we want to build a key reminder as part of the smart home system to avoid these embarrassing and really inconvenient situations. With this helper, we could foster a good habit of dropping the key to a given location for later use, as well as be reminded in time when we exit the room. In addition to the key reminding function, the system can also remind people to close the door for the house safety. We also consider the situation that when coming home late at night, people struggle to find the lamp switch at the door, so a light operated illumination LED is armed. Lastly, we install a button to disable and enable the reminder, given the situations when people need to go in and out frequently in a short time. In general, we develop this key reminder system to make our daily life more convenient. And we think it would be helpful to many of us suffering the similar annoying problem.
What it does
The input of the system includes 2 motion sensors to detect the door and human motion, one switch snap action to detect the presence of the key and a photoresist to sense the light in the room. The output consists of a built-in buzzer to remind taking or dropping the key, an addressable controlled LED strip to remind closing the door, three white LEDs near the lamp switch for illumination. Besides, a disable and enable button is armed for the user to switch the working mode of the reminder.
How I built it
Sensor 1 is to detect the motion of the human near the door within the room, sensor 2 is to detect the motion and the close of the door, A plastic hook is connected to the switch snap action to detect the presence of the key. Input capture interrupt:
When the door motion sensor detects motion of the door, the sensor will output a high signal. The input capture will be triggered at the rising edge. In the interrupt, the interrupt function will be enabled. The door status variable will be toggled. If the door is open, If the human motion sensor is triggered, meaning it’s leaving, the LED strip will be turned on in green. If the switch of the hook is in high state, meaning the key is on the hook, the buzzer will sound with a duty cycle of 20% until the switch is in low state. If the human motion sensor is not triggered, meaning it’s entering, the LED strip will be turned on in red. If the switch of the hook is in low state, meaning the key is off the hook, the buzzer will sound with a duty cycle of 20% until the switch is in high state. If the door is closed, the white LED will be turned off as well as the LED strip.
Pin change interrupt: When the disable/enable button is pressed, jump into the pin change ISR to turn the LED strip off and disable the door motion sensor by making the pin to be input pin to avoid receiving any sensing signal. So that when people go in and out, the input capture interrupt won’t be triggered, thus no reminding action will be proceeded. When the button is pressed again, the motion sensor 2 will be enabled by setting the pin to be output and system functions again.
ADC: The photo-resistor is connected to the ADC pin. Within the ADC ISR, check the ADC value, if it is below 300 which means the room is dim, set the global constant brightness to be 0, otherwise, to be 1, which is used as the judging condition of whether to turn on the illumination in input capture ISR.
Challenges I ran into
We have encountered some problems during this project. The first problem is initially, we planned to use the obstacle sensor to detect the motion of door opening and closing. However, we found that the sensor triggered multiple times when opening or closing the door, repeatedly triggering the input capture interrupts. This is undesired because we count the triggering times to determine whether it’s opening or closing the door. So, we replaced the obstacle sensor with another motion sensor that is able to be triggered only once when door motion is detected. But the motion sensor has wider detection angles and is too sensitive for this application. So we removed the shell of the sensor and covered the peripheral of the sensor to reduce the sensing range.
Another problem is that the system cannot get into another interrupt when it is already in an ISR. For example, we want to turn a LED off or disable the door motion sensor by pressing a button. So we write a pin change interrupt to achieve this function. However, these actions are all executed after the door is open and they should happen after the door motion interrupt but they cannot. After some effort and help from Kim, we decided to re-enable the interrupt function at the beginning of the ISR since by default all interrupt will be disabled after entering an ISR.
Accomplishments that I'm proud of
Leaving the room: As people approach and open the door, Buzzer rings to remind people to take the key. The LED strip lights up in green to remind us to close the door. Once the key is taken, the buzzer will stop ringing, when the door is closed, the LED strip is turned off. If the door is left open, the LED will be lit up till the door is closed.
Entering the room: When the door is opened from outside, the buzzer will ring in a different frequency and the LED strip will light up in red. The white LED will turn on if the room is too dim. When the key is put on the hook, the buzzer stops ringing, when the door is closed, the LED will be turned off. If the door is left open, the LED will be lit up till the door is closed.
Disable mode: When we need to go in and out multiple times. We can disable the reminder system by pressing the disable/enable button. The door motion sensor will be disabled and stop reminding us to close the door.
What I learned
Firstly, we have learned the working principles of the new sensors, the obstacle avoidance sensor, motion sensor and the switch snap action, and also the interesting addressable LED strip. One thing we are very proud of is that not only the system can achieve the individual functions separately, but it also can function as we expected under the real condition when all the functions are combined. From this project, we learned how to build an embedded system from the beginning since we don’t have any experience on embedded systems before this course. When designing an embedded system, we first need to narrow down the scope of the problem. For example, we want to design a key reminder system. We can narrow it down to when we will need this system. We need the system to remind us to take or bring the key when we are leaving or coming home. Next, we need to decide what the key reminder system will do. The system will give sound alerts when we forget to take or put on the key. Next, we need to plan how the system will accomplish it. We chose a motion sensor to detect when we open the door and switch to detect if the key is on the hook and also buzzer to remind us of the key. Last, we design and implement the system and verify the functionality of the system. During the process we have optimized the function of our system considering the real cases to make the system more convenient to use, like the addition of the disable and enable function.
What's next for Smart Home: The Key Reminder
The further developments of the system could be: replace the buzzer with the module that plays pre-recorded audio files for the key reminding. Arm with multiple hooks and switch snap actions for the family use (multiple keys). Develop evening mode to protect the house, avoid the invasion. If someone enters the safety range of the room the user set, ALERT.