Inspiration
We were inspired by roommates snooping in on our personal drawers so we wanted to create an alarm to go off when the drawer was opened.
What it does
This device uses a ping sensor to detect if a drawer has been opened or not by seeing the distance above the sensor. It then displays an alert on an LCD screen and an alarm sounds when the drawer is opened. Additionally, it uses IOT to call a certain phone number when the drawer is opened. The alarm only stops when disarmed by pressing the button.
How we built it
We used a ping sensor, Arduino, NodeMCU, buzzer, LCD screen, button, and breadboard to complete this project by making sure all of the parts interface correctly, allowing the alarm to trigger when the drawer is opened.
Challenges we ran into
The largest challenge we ran into was using the IOT component. At first we tried to use the NodeMCU module to send a notification to a phone when prompted, but this proved difficult so we began trying alternative methods of using IOT. We finally were able to use IOT and the NodeMCU to call a phone number when the drawer is opened.
Accomplishments that we're proud of
One accomplishment we are proud of is being able to use the LCD display to display a message when the door is opened. We are also very proud of being able to use IOT to call a phone number when the drawer is opened.
What We Learned
We learned how to use the NodeMCU for the first time and how to make two different portions of code interface between the Arduino and NodeMCU. We also learned how to program the button and LCD screen.
Code Breakdown
Firstly we have the code that determines whether the drawer is open or close by reading the whether the distance read is near or far.
long duration , distance;
digitalWrite (trigPin , LOW );
delayMicroseconds (2);
digitalWrite (trigPin , HIGH );
delayMicroseconds (10);
digitalWrite (trigPin , LOW );
duration = pulseIn (echoPin , HIGH );
distance = (duration / 2) / 29.1; //Calculate the distance of the reflecting surface in cm
Up next we have our off alarm loop that will read "Drawer Closed" when the drawer is closed.
if (distance<20){
digitalWrite(buzzerPin, LOW);
digitalWrite(redPin, LOW);
digitalWrite(greenPin, HIGH);
delay(10); // green
Serial.println("Drawer Closed");
lcd.setCursor(0, 0);
lcd.print("Drawer Closed ");
lcd.setCursor(0, 1);
lcd.print(" ");
digitalWrite(10, LOW);
delay(1000);
}
The bread and butter of our code is the alarm loop, that once triggered will continue to loop until a disarm button is pressed. During the alarm pin 10 reads HIGH which is sent to the MCU which interprets this signal and sends a value to the cloud which will cause it to call the user.
if (distance>=20){
while(1) {
digitalWrite(10, HIGH);
Serial.println("ALARM!");
lcd.setCursor(0, 0);
lcd.print("ALARM! ");
lcd.setCursor(0, 1);
lcd.print(" ");
digitalWrite(buzzerPin, HIGH);
digitalRead(7);
if (digitalRead(7) == HIGH) {
digitalWrite(7) == LOW;
break;
}
Up next we have the code to our MCU. The MCU is the cornerstone of our IoT component. Our functional code is relatively small for our MCU as it only serves the purpose of relaying information to Adafruit which then call our phone to alert the alarm is going off.
void loop() {
io.run();
if (digitalRead(5) == HIGH){
Drawer->save(3);
}
if (digitalRead(5) == LOW){
Drawer->save(1);
}
delay(5000);
}
The code is rather simple. It simply checks if pin5 is receiving power or not. In our arduino code we set sent a HIGH voltage to pin 5 on the MCU to tell it the alarm is going off. When the alarm goes off pin 5 is set to high so the MCU sends a 3 to Adafruit. When adafruit reads a value x > 3 it will call the user, alerting them of the alarm. When the alarm is turned off/isn't triggered, the MCU sends the value 1 which stops adafruit from calling the user.
What's next for Secret Drawer Sensor
Next for Secret Drawer Sensor would be to finally create a notification system to alert the owner every-time the drawer is opened and adding more protective casing to the outside of the product.

Log in or sign up for Devpost to join the conversation.