Justin_time23Logan Williams
Published © GPL3+

Particle Photon Mail Detector Fall 2018 3171

Do you ever wonder when the mail man delivers your mail? Well worry no more, we have the device for you.

Easy24 hours45
Particle Photon Mail Detector Fall 2018 3171

Things used in this project

Hardware components

Photon
Particle Photon
×2
Grove - PIR Motion Sensor
Seeed Grove - PIR Motion Sensor
×1
Male/Male Jumper Wires
×7
Male/Female Jumper Wires
Male/Female Jumper Wires
×3
Adafruit SSD1306 OLED Display
×1
Micro-USB to USB Cable (Generic)
Micro-USB to USB Cable (Generic)
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×2

Software apps and online services

Particle Pi
Particle Pi
Fritzing
Maker service
IFTTT Maker service

Story

Read more

Schematics

Display Pin Diagram

Pin out for Particle Photon to OLED display
Display qniem2vuv4

PIR Motion Sensor Pin Diagram

Pin out for the PIR Sensor
Pir 6qfimmufeu

Code

Motion Detector

C/C++
// This #include statement was automatically added by the Particle IDE.
#include <Adafruit_SSD1306.h>


int PIRSensor = D0;
int led = D7;
int var=0;
int last=0;

void setup() 
{
    pinMode(led, OUTPUT);
    Particle.subscribe("LEDoff2018", myHandler, "2f0017000d47363330353437");
 
}

void myHandler(const char *event, const char *data)
{
    digitalWrite(led, LOW);
}

void loop() {
    
    var=digitalRead(PIRSensor);
    if((digitalRead(PIRSensor) == HIGH) && (last == LOW))
    {
        digitalWrite(led, HIGH);
        
       
        String data = String(var);
        // stuff happens here
      
        Particle.publish("YHM2018", "motion is detected");
     
    }

    last = var;
   
    if(digitalRead(PIRSensor) == LOW)
    {
        last = 0;
       
    }
    delay(10000);
}

OLED Display

C/C++
// This #include statement was automatically added by the Particle IDE.
#include <Adafruit_SSD1306.h>


// use hardware SPI
#define OLED_DC     D3
#define OLED_CS     D4
#define OLED_RESET  D5
Adafruit_SSD1306 display(OLED_DC, OLED_RESET, OLED_CS);


//int  x, minX; // variables for scrolling code

void setup() {
    
    Particle.subscribe("YHM2018", myHandler, "2f0021000d47363330353437");
    

}

void loop() {delay(1);
}

void myHandler(const char *event, const char *data) {
  
  display.begin(SSD1306_SWITCHCAPVCC);


 display.setTextSize(2);       // text size
  display.setTextColor(WHITE); // text color
  display.clearDisplay();
  display.println("You Have");
  display.println("Mail");
  display.display();
  delay(10000);
  
  display.setCursor(0,0);
  display.clearDisplay();
  display.display();

Particle.publish("LEDoff2018", "led off");
}

Credits

Justin_time23

Justin_time23

0 projects • 0 followers
Logan Williams

Logan Williams

0 projects • 0 followers

Comments

Add projectSign up / Login