Nicholas Meltonantonio kraychete
Published

You got mail!

Tired of having to walk out in the cold rain to see if you got mail? Well don't worry anymore! "You got mail!" is here to save the day!

IntermediateFull instructions provided750
You got mail!

Things used in this project

Hardware components

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

Software apps and online services

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

Story

Read more

Schematics

At Home Circuit

This circuit is used to flash an LED light when your mailbox has been opened and when it is closed which sends an email to you, notifying when mail has arrived

Mailbox Circuit

This is the circuit used in the mailbox connecting the proximity sensors to the particle cloud to notify when the mailbox has been opened and closed.

Code

House Code

C/C++
int ledPin = D6;                // LED Pin


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

 void myHandler(const char *event, const char *data)
 {
  Particle.publish("mail_new", "New Mail", PRIVATE);
  digitalWrite(D7,HIGH);
  digitalWrite(ledPin, HIGH);
  delay(1000);
  digitalWrite(ledPin, LOW);
  delay(1000);
  digitalWrite(ledPin, HIGH);
  delay(1000);
  digitalWrite(ledPin, LOW);
  delay(1000);
  digitalWrite(ledPin, HIGH);
  delay(1000);
  digitalWrite(ledPin, LOW);
  delay(1000);}
  
  void loop() {
      
  }
 

Mailbox Code

C/C++
SYSTEM_THREAD(ENABLED);

SYSTEM_MODE(AUTOMATIC);  

int inputPin = D6;              
int light = D4;
int pirState = LOW;             
int val = 0;                    
                
int calibrateTime = 5000;   

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

void loop() {

  if (calibrated()) {

    readTheSensor();

    reportTheData();
    }
}

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

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


void reportTheData() {
    if (val == HIGH) {
        
        if (pirState == LOW) {
         
         Particle.publish("mail_new", "Mailbox Open", PUBLIC);
          
          pirState = HIGH;
                 }
    } else {
        if (pirState == HIGH) {
       
          Particle.publish("mail_new", "Mailbox Closed", PUBLIC);
          pirState = LOW;
                  }
    }
}

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

Credits

Nicholas Melton

Nicholas Melton

1 project • 0 followers
antonio kraychete

antonio kraychete

1 project • 0 followers

Comments