Smart Mailbox

Made by Ryan Stinebaugh

This Device turns any mailbox into a connected device by alerting the user via email when new mail has been received. It also has an off switch for notifications for when the user goes to collect their mail from the box.

Created: January 25th, 2018

0

Problem Statement

My parent's house has a mailbox that is pretty far from the front door. Because of this, they frequently have to walk out and check to see if there has been new mail delivered. It can be very hot in the summer months where I live, so walking out to the mailbox is not a fun occasion, especially when there is no new mail to be found. If only there was a way to be notified within the comfort of one's home that they have received mail.

0

Goal

The solution to this problem is to add a connected device to the mailbox that can detect when the mailbox is opened or closed. While there are several ways to do this, I opted for light detection, as that would be the easiest way to integrate with and existing mailbox. This device will need to be in range of a WI-FI connection, so that it will be able to relay the information to the user. Since we are dealing with mail, I thought sending an email to the user of the notification would be most appropriate. This device solves the problem because the user can be sent a notification from anywhere connected to the internet that new mail has been added to their mailbox.  

0

Process

I started by building only the circuit with the photo resistor to gauge what values I needed in my code to be able to determine when the box was opened or closed. Once I found the right balance, I hooked the code up to IFFT to send myself an email once the box was opened.

0

I next added an LED to indicate the status of the box. The light will turn on when the box is opened and turn off when the box is closed. I updated the code to incorporate the LED.

0

For the final touch, I added a three pronged switch. When the switch is off, the LED blinks rapidly and the photo resistor is no longer actively checking to see if the box is opened or closed. This is to avoid the situation when the user is going to collect the mail and obviously doesn't need the notification via email that the mailbox has been opened. To code this, I added a placed the previous code inside of a if  statement and gave and made an else statement for the flashing light.

0

Final Code

0
int photoresistor = A1;
int lightState = 0;
int lightStatus = 0;
int previousLightStatus = 0;
int lightCheck = 0;
int ledPin = D0;
int switchPin = D1;

void setup() {
  pinMode(photoresistor, INPUT);
  pinMode(ledPin, OUTPUT);
  Particle.variable("lightState", lightState);
  Particle.variable("lightCheck", lightCheck);
  Particle.variable("lightStatus", lightStatus);
  pinMode( switchPin , INPUT_PULLUP); // sets pin as input
  pinMode( ledPin , OUTPUT ); // sets pin as output
}

void loop() {
  int buttonState = digitalRead( switchPin );
  if( buttonState == LOW ) {
    lightCheck = analogRead(photoresistor);
    if (lightCheck > 100) {
      lightStatus = 1;
      digitalWrite(ledPin,HIGH);
    }
    else {
    lightStatus = 0;
    digitalWrite(ledPin,LOW);
    }
    delay(100);
    if (previousLightStatus == 0 && lightStatus == 1) {
      Particle.publish("lightState","Light detected");

    }
    previousLightStatus = lightStatus;
  }
  else {
    digitalWrite(ledPin,HIGH);
    delay(100);
    digitalWrite(ledPin,LOW);
    delay(100);
  }
}
Click to Expand
0

Circuit Diagram

0

Parts

1 x Particle Photon

1 x Photo resistor

5 x Jumper Wires

6 x Jumper Cables

2 x 1KΩ  Resistor

1 x Switch

1 x LED


0

Video and Output Verification

Below is the video showcasing the device. The LED lights up when the box is opened and no notification is sent when the switch is flipped.  Also below are the console outputs in particle and the respective emails tied to the "Light Detected" published event.

0

Reflection

If I were to do this project over again, I would move the switch to the box itself instead of being on the particle photon. Right now if my design were to be used with the whole system inside of the mailbox, the switch would only be able to be reached once the box was opened making its purpose useless. I could also change the switch to a different type of input method such as a button. Another way I could change this design is to split the functionality between two particle photons. On the device inside of the box it would house the photo resistor, and the second would have the LED and switch for notifications. I think I got to where I wanted to with this project, as I was proud to get the device working and have more features than I originally imagined.

x
Share this Project

Courses

49313 Designing for the Internet of Things (Undergrad)

· 22 members

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


About

This Device turns any mailbox into a connected device by alerting the user via email when new mail has been received. It also has an off switch for notifications for when the user goes to collect their mail from the box.