Don't Lock Me Out

Made by Mengyang Hong

Found in DIoT 2018 1- Home Hack

A device that can prevent my housemates from being accidentally locked outside when they return late during midnight.

0
IoT Diagram
Doorlock iot diagram
0

Proposal:

A frustrating experience I have identified for my housemates (and myself) is that sometimes we stayed at the school library/studio or hung out with friends until late in the midnight and forgot to tell others in advance, which sometimes resulted in one of us got accidentally locked outside when we went back. (We have the habit of locking the house gate from the inner side using a knob before going to bed for safety concerns, in which way the door could not be opened with a key from outside.) 

To solve this problem, I plan to develop an IoT device that can send a text message notification to everyone once someone locks the gate from the inner side, therefore we can react to it quickly.  To realize this function, I plan to put a tilt sensor on the lock (knob) and connect it to a Photon. The Phonton will then integrate with Twilio API to text messages.

1
Working Prototype
0

Process:

The making process of this project can be divided into 3 steps: 

1. Design a simple circuit that contains an LED as a status indicator, a tilt sensor as an input for triggering events, and a resistor to protect electric components. 

2. Develop code on Particle IDE for controlling the circuit to work as we intended:

- Turn on the LED light when the tilt sensor is tilted, and turn off the LED light when the sensor goes back to the default vertical position.    

- Make sure the tilt sensor functions properly.

- Enable a cloud variable (the status of the tilt sensor) to be inspected.

- Add proper delay to avoid the loop going overwhelmingly frequent.

3.  Integrate Twilio API by adding a webhook on Particle console. Add lines of code to enable Photon to publish events and get responses from Twilio properly. Finally, ensure that messages should be sent to the user under the correct condition.

0
Circuit Diagram
Doorlock circuit diagram
0
Code
int ledPin = D0;
int tiltPin = D4;
int tiltReading;
int previous = 0;
String body = "Your housemate has just locked the door!";


void setup()
{
  pinMode(ledPin, OUTPUT);
  pinMode(tiltPin, INPUT_PULLUP);
  Particle.variable("tiltSensor", tiltReading );
}


void loop()
{
  tiltReading = digitalRead(tiltPin);

  if( tiltReading == 1 )
      {
        // make sure once the sensor is tilted and stays in that position, the notification won't keep sending
        if( tiltReading != previous )
          {
            // turn the LED On
            digitalWrite( ledPin, HIGH);
            // publish an event to Particle console
            Particle.publish( "iveBeenTilted" );
            Particle.publish("twilio_sms", body, PRIVATE);
            previous = tiltReading;
          }

      }else{
       // otherwise
       // turn the LED Off
       digitalWrite( ledPin, LOW);
       previous = tiltReading;

      }
  delay(2000);

}
Click to Expand
0
Particle Console Event Page
Particle console
0

Parts:

  • Particle Photon x 1
  • Breadboard x 1
  • Tilt Sensor x 1
  • LED x 1
  • 1kΩ Resistor x 1
  • Jumper Wires 


Webhook:

  • Twilio API
x
Share this Project

Courses

49713 Designing for the Internet of Things

· 25 members

A hands-on introductory course exploring the Internet of Things and connected product experiences.


Focused on
About

A device that can prevent my housemates from being accidentally locked outside when they return late during midnight.

Created

January 25th, 2018