Things used in this project

Hardware components:
Photon new
Particle Photon
×1
13285 01
PIR Motion Sensor (generic)
×1
Belkin WEMO Smart Outlet
×1
Software apps and online services:
Hackster
ThingSpeak API
IFTTT

Schematics

PIR Pin Out Schematic
PIR Pin Out
Iq7u4rimdgeozbvyahe1 m8bl8ryxeh

Code

PIR CodeC/C++
The code for the Photon to publish if the PIR sensor detects motion.
/*                          +-----+
 *               +----------| USB |----------+
 *               |          +-----+       *  |
 *               | [ ] VIN           3V3 [*] |<-------Power To PIR Sensor
 *               | [ ] GND           RST [ ] |
 *               | [ ] TX           VBAT [ ] |
 *               | [ ] RX  [S]   [R] GND [*] |<-------Ground for PIR Sensor
 *               | [ ] WKP            D7 [ ] |       
 *               | [ ] DAC +-------+  D6 [ ] |       
 *               | [ ] A5  |   *   |  D5 [ ] |       
 *               | [ ] A4  |Photon |  D4 [ ] |     
 *               | [ ] A3  |       |  D3 [ ] |
 *               | [ ] A2  +-------+  D2 [ ] |
 *               | [ ] A1             D1 [ ] |
 *               | [ ] A0             D0 [*] |<-------Signal from PIR Sensor
 *               |                           |
 *                \    []         [______]  /
 *                 \_______________________/
 */
int PIR = D0;//sets PIR equal to pin D0
int led = D7;
void setup() {
    pinMode(PIR, INPUT);
    //sets pin D0 as an input
    pinMode(led, OUTPUT);
}

void loop() {
    int pirValState;

  pirValState = digitalRead(PIR);
  
    if (pirValState == LOW){
        digitalWrite(led, HIGH);
        Particle.publish("jcashwell15", "office-motion");
    delay(5000);
    //if the PIR pin reads a HIGH signal then it will trigger the publish command
    }
}
Reciever CodeC/C++
This is the code for the second photon to turn on the lights if the PIR code published.
// This #include statement was automatically added by the Particle IDE.
#include <ThingSpeak.h>

void loop1() {
  // Get some data
  String data = String(10);
  // Trigger the integration
  Particle.publish("Light-On", data, PRIVATE);
  // Wait 60 seconds
  delay(60000);
}

void setup1() {
  // Subscribe to the integration response event
  Particle.subscribe("hook-response/Light-On", myHandler, MY_DEVICES);
}


void setup() {
Particle.subscribe("jcashwell15", myHandler);
}

void myHandler(const char *event, const char *data){
    //int num = (strcmp(data,"office-motion"));
   // delay(1000);
    if (strcmp(data,"office-motion")==0){
        Particle.publish("Light-On","jcashwell3");
    }
}

Credits

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

What's My I2C Address?
Easy
  • 72
  • 3

The story of how to make a clock through using a LCD 1602 or LCD 2004 over I2C.

MyHumidity Controlled by BME280 and Photon
Easy
  • 181
  • 4

Full instructions

Checks if humidity threshold is reached and informs the user by using Blynk/IFTTT-services with softAP integration.

Tweeting Particle Photon
Easy
  • 42
  • 1

Full instructions

Tweet your friends with only the press of a button!

MyLight-Clock with NeoPixel Ring 12 Controlled by Photon
Easy
  • 260
  • 2

Full instructions

Read the time at night? Without glasses? Impossible? Focus on 2 light points, which will tell you the hour and the minute.

Map Your Particles!
Easy
  • 1,354
  • 20

Protip

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

BME280 measures and displays on OLED controlled by Photon
Easy
  • 340
  • 2

Protip

I share my first steps with the sensor BME280 (temp / humi / pressure / altitude) and an OLED 128 * 64 px

Add projectSign up / Login