Mailbox Sensor

Made by Ashwin Ramesh

To create a device that sends an email every time my mailbox is opened.

Created: January 30th, 2016

0

Intention

My roommates and I hardly check our mailbox. Sometimes, the mails stack up. After a while, the mails stack up. A simple device that alerts us about new mail would be helpful.
0

Goal

The goal is to create a device that sends an email every time my mailbox is opened.

0

Process

The device uses an LED and a PIR sensor. Every time the PIR sensor detects motion, the LED lights up. The Particle photon is connected to the Wi-FI at home. So, the device sends an email notifying me about this event.


Components

Particle Photon

PIR Sensor

LED ( Red ) : Motion Indication

1 Resistors 1k ohms

Jumper wires

0

Outcome

...
0

Reflection

This is my first IOT project. There are lots of room for improvement. For example, the time of day when a mailbox is opened could be used to make the sensor more efficient. The sensor can be dormant at night. The sensor and particle photon could be housed in a well designed box.

I look forward to creating cool home automation based projects in the future.

Stay tuned.

0
Code
#include <time.h>
int inputPin = D2;
int lightPin = D0;
int val = 0;                   // variable for reading the pin status
int lastMailReceivedAt = 0;
int currentTime = 0;

void setup() {
  /*Initialize*/
  pinMode(inputPin, INPUT);     // declare sensor as input
  pinMode(lightPin, OUTPUT);
  lastMailReceivedAt = Time.now();
  Serial.begin(9600);
  digitalWrite(lightPin, LOW);
}

void loop() {
  val = digitalRead(inputPin);  // Read PIR sensor input value
  if( val == 1 ) {
    digitalWrite(lightPin, HIGH);
    currentTime = Time.now();
    /*If condition based on 30 seconds threshold, for email notification*/
    if(currentTime - lastMailReceivedAt > 30 ) {
      Particle.publish("motion-detected","You got mail", PRIVATE);
      lastMailReceivedAt = Time.now();
      delay(1000);
      digitalWrite(lightPin, LOW);
    }
  }
}
Click to Expand
x
Share this Project

Courses

49-713 Designing for the Internet of Things

· 4 members

This course charts the emergence of the now "connected world" to explore the possibilities for future products and connected spaces.


About

To create a device that sends an email every time my mailbox is opened.