Daniel KieszClayton Cartner
Published

MEGR 3171 Mailbox Notification System

Done with the days of going to the mailbox to find that it hasn't come yet or someone else has picked it up. Our system gives you control.

IntermediateShowcase (no instructions)411
MEGR 3171 Mailbox Notification System

Things used in this project

Hardware components

Photon
Particle Photon
×2
Breadboard (generic)
Breadboard (generic)
×2
LED (generic)
LED (generic)
×1
AA Batteries
AA Batteries
×8
4xAA battery holder
4xAA battery holder
×2
Resistor 1k ohm
Resistor 1k ohm
×2
Jumper wires (generic)
Jumper wires (generic)
×2
Magnetic Proximity Sensor, Sensor and Magnet
Magnetic Proximity Sensor, Sensor and Magnet
×1

Software apps and online services

Google Sheets
Google Sheets
Maker service
IFTTT Maker service
Particle Build Web IDE
Particle Build Web IDE

Story

Read more

Schematics

In Home Diagram

Diagram for in home setup.

In Mailbox Diagram

Diagram for in mailbox set up

Code

In Mailbox

C/C++
This photon uses a magnetic sensor to detect if the mailbox is open or closed. When an event occurs, the activity is sent to the in home photon.
// Mailbox notification system

SYSTEM_THREAD(ENABLED); //Enable multitasking.  Allows the ability to catch the mailpin trigger and send the message.

SYSTEM_MODE(AUTOMATIC);  //Run code, then connect.

int inputPin = D0;              
int light = D4;
int pirState = LOW;             // no motion detected
int val = 0;                    // variable for pin status
                  // Variable for pin status

int calibrateTime = 30000;   

void setup() {
    pinMode(light, OUTPUT);
    pinMode(inputPin, INPUT);  
    Particle.subscribe ("newmail", myHandler);
}

void loop() {

  if (calibrated()) {

    readTheSensor();

    reportTheData();
    }
}

void readTheSensor() {
    val = digitalRead(inputPin);
}

bool calibrated() {
    return millis() - calibrateTime > 0;
}


void reportTheData() {
    if (val == HIGH) {
        // the current state is no motion
        // announce this change by publishing an event
        if (pirState == LOW) {
          // we have just turned on
         Particle.publish("Mailbox", "Mailbox Open", PUBLIC);
          // Update the current state
          pirState = HIGH;
                 }
    } else {
        if (pirState == HIGH) {
          // we have just turned off
          // Update the current state
          Particle.publish("Mailbox", "Mailbox Closed", PUBLIC);
          pirState = LOW;
                  }
    }
}

void myHandler(const char *event, const char *data) {
    digitalWrite (light, HIGH);
    delay(1500);
    digitalWrite (light, LOW);
}

In Home

C/C++
This photon communicates with the in mailbox photon to activate a LED light if the mailbox has been opened. Once the photon reads this it sends a message back to the in mailbox system notifying that it received the message.
int ledPin = D0;                // LED Pin


void setup() {
    pinMode(ledPin, OUTPUT);
    Particle.subscribe("Mailbox", myHandler);
}

 void myHandler(const char *event, const char *data) {
  Particle.publish("newmail", "New Mail", PUBLIC);
  digitalWrite(D7,HIGH);
  digitalWrite(ledPin, HIGH);
  delay(100);
  digitalWrite(ledPin, LOW);
  delay(100);
  digitalWrite(ledPin, HIGH);
  delay(100);
  digitalWrite(ledPin, LOW);
  delay(100);
  digitalWrite(ledPin, HIGH);
  delay(100);
  digitalWrite(ledPin, LOW);
  delay(100);
  digitalWrite(ledPin, HIGH);
  delay(500);
  digitalWrite(ledPin, LOW);
  delay(500);
  digitalWrite(ledPin, HIGH);
  delay(500);
  digitalWrite(ledPin, LOW);
  delay(500);
  digitalWrite(ledPin, HIGH);
  delay(1000);
  digitalWrite(ledPin, LOW);
  delay(1000);
  digitalWrite(ledPin, HIGH);
  delay(500);
  digitalWrite(ledPin, LOW);
  delay(500);
  digitalWrite(ledPin, HIGH);
  delay(100);
  digitalWrite(ledPin, LOW);
  delay(100);
  digitalWrite(ledPin, HIGH);
  delay(100);
  digitalWrite(ledPin, LOW);
  delay(100);
  digitalWrite(ledPin, HIGH);
  delay(100);
  digitalWrite(ledPin, LOW);
  delay(15000);
}


void loop() {}

Credits

Daniel Kiesz

Daniel Kiesz

1 project • 0 followers
Clayton Cartner

Clayton Cartner

1 project • 0 followers

Comments

Add projectSign up / Login