Mitchell ChristenberryChad Messick
Published © GPL3+

Mail In Your Box IoT

Ever wonder if the mailman has been by the house yet? Use this IoT project to know exactly when your important package has been delivered!

IntermediateFull instructions provided6 hours14

Things used in this project

Hardware components

Photon
Particle Photon
×2
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×2
Male/Female Jumper Wires
Male/Female Jumper Wires
×3
Male/Male Jumper Wires
×4
5 mm LED: Yellow
5 mm LED: Yellow
×1
Resistor 221 ohm
Resistor 221 ohm
×1
Buzzer
Buzzer
×1
Grove - PIR Motion Sensor
Seeed Grove - PIR Motion Sensor
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1

Software apps and online services

Maker service
IFTTT Maker service
Google Sheets
Google Sheets

Story

Read more

Schematics

Sensor Photon Circuit

Diagram for sensor rh24ntydn5

Buzzer/LED Photon Circuit

Diagram for buzzer wd6kxv6p2m

Code

Sensor Code

C/C++
This code is used to notify the photon of a signal from the motion sensor. From this signal the photon will communicate to the other photon on the same network that they are both connected to.
int pirState = LOW;             
int value = 0;    
int inputpin = D0;             
int calibratetime = 5000;
int mail = 1;
int LED = D7;


void setup() {
pinMode(inputpin, INPUT);
pinMode(D7, OUTPUT);
Particle.subscribe("got_mail",sensor, "410037000b47363330353437");
}

 void sensor(const char *event, const char *data){
        digitalWrite(LED, HIGH);
        delay(1000);
        digitalWrite(LED, LOW);
        
 }

void loop() {
    if (calibrated())
    {
    sensorread();
    reportdata();
    }
    
    }
    
void sensorread() {
    value = digitalRead(inputpin);
    delay(10000);
}

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

void reportdata() {
    if (value == HIGH) {
        mail = mail;
        Particle.publish("YGM", "1");
        delay(10000);
    }
    else if (value == LOW) {
        mail = 0;
    }
}

Buzzer/LED Code

C/C++
This purpose of this code is to receive the signal from the other photon and transfer that signal to the buzzer and the LED light when the mailbox has been opened.
int Buzzer = D0;
int state = 0;
int sensor = 1;


void setup ()
{
    pinMode(Buzzer,OUTPUT);
    Particle.subscribe("YGM",mail, "380029000b47363330353437");
}

void mail(const char *YGM, const char *mail)
{
     Particle.publish("got_mail", String(sensor));
      digitalWrite(Buzzer,HIGH);
      delay(1000);
      digitalWrite(Buzzer,LOW);
      
      delay(500);
      digitalWrite(Buzzer,HIGH);
      delay(1000);
      digitalWrite(Buzzer,LOW);
      
      delay(500);
      digitalWrite(Buzzer,HIGH);
      delay(1000);
      digitalWrite(Buzzer,LOW);
}

Credits

Mitchell Christenberry

Mitchell Christenberry

0 projects • 0 followers
Chad Messick

Chad Messick

0 projects • 0 followers

Comments

Add projectSign up / Login