Things used in this project

Hardware components:
Photon new
Particle Photon
in my case I used a Particle/Spark Core
×1
13285 01
PIR Motion Sensor (generic)
×1
Adafruit industries ada1536 image
Buzzer
active buzzer thats makes "peep"
×1
09590 01
LED (generic)
×1
Mfr 25frf52 1k sml
Resistor 1k ohm
×1
11026 02
Jumper wires (generic)
counted around 7
×1
12002 04
Breadboard (generic)
×1
Software apps and online services:
Q8wtlimqnp04fzhtr9v5
IFTTT Maker service

Schematics

Schematic
Mypir sensor informs me via ifttt sketch steckplatine meuqxjhews

Code

Ingos CodeC/C++
// PIR Sensor triggers IFTTT-Services to inform a motion detection

// Ingo Lohs, v1.0 - 17.05.2017

int inputPin = D0;              // choose the input pin (for PIR sensor)
int ledPin = D1;                // LED Pin
int buzzerPin = D2;             // Sound in case of motion detected
int pirState = LOW;             // we start, assuming no motion detected
int val = 0;                    // variable for reading the pin status
int boardLed = D7;              // photon onBoard LED
int calibrateTime = 10000;      // wait for the thingy to calibrate

void setup() {

  pinMode(boardLed,OUTPUT);     // on-board LED 
  pinMode(ledPin, OUTPUT);
  pinMode(buzzerPin, OUTPUT);
  pinMode(inputPin, INPUT);     // declare sensor as input
  
     // Now flash the D7 LED on and off 
  digitalWrite(boardLed,HIGH); // Start der Kallibrierung mit D7 on
  Particle.publish("Nicks Security Project","now online",100,PRIVATE);
  digitalWrite(boardLed,LOW); // Start der Kallibrierung mit D7 off

}
 
void loop() {
  
  // if the sensor is calibrated
  if ( calibrated() )
  {
  // get the data from the sensor
    readTheSensor();

    // report it out, if the state has changed
    reportTheData();
  }
}
 


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


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


void reportTheData() {

  // if the sensor reads high
  // or there is now motion
  if (val == HIGH) {

    // the current state is no motion
    // i.e. it's just changed
    // announce this change by publishing an eent
    if (pirState == LOW) {
      // we have just turned on
      Particle.publish("Nicks Security Project", "Motion detected", PRIVATE);

      pirState = HIGH;
      setLED( pirState );

    }
  } else {
    if (pirState == HIGH) {
      // we have just turned of
      // Update the current state
      pirState = LOW;
      setLED( pirState );
    }
  }
}


void setLED( int state )
{
  digitalWrite( ledPin, state );
  digitalWrite( buzzerPin, state );
  delay(3000);
}

Credits

Img 6554 3ywwumwxbh
Ingo Lohs

I am Ingo, well over 40 years and come from the middle of Germany. You can contact me in English or German.

Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Map Your Particles!
Easy
  • 463
  • 12

Protip

Locate your Particle Photons, P1s and Electrons on a map without needing extra hardware. Use Ubidots or an offline map alternative

Boost Your Google Home With Prota OS for RPi
Easy
  • 2,242
  • 9

Full instructions

Extend your Google Home features to smart light, smart speakers, smart cam and smart appliances with those DIY tricks based on Raspberry Pi.

Sending Photos and Video Over the Internet!
Easy
  • 1,934
  • 27

Full instructions

Record video, perform object and face recognition, take a time-lapse or whatever else with a Particle Photon and the 5-megapixel Arducam!

Google Home - Control DIY Devices
Easy
  • 905
  • 10

Full instructions

This project show how to control multiple IoT devices using Google Home.

Text Machine, Get Gumball
Easy
  • 50
  • 1

This project describes how to build an Arduino-based, text-controlled gum dispenser

Power Supply Module 3.3V and 5V
Easy
  • 20
  • 0

Protip

First test of a separate Power Supply Module 3.3V and 5V

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login
Feedback