Cameron PalkowskiRobert Cook
Published

The Intrudalert

The Intrudalert creates an invisible IoT turnstile, which can be used for theft prevention and store monitoring.

IntermediateShowcase (no instructions)4 hours458
The Intrudalert

Things used in this project

Hardware components

Photon
Particle Photon
×2
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×2
PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
×2
Jumper wires (generic)
Jumper wires (generic)
×9
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×2

Story

Read more

Schematics

Intrudalert Measuring System Schematic

The measuring system consists of a Particle Photon (1) and PIR sensors (2). The PIR sensors should be placed so that one "sees" the entrance and the other "sees" the exit. It is imperative that they do not pick up the same motion from a single direction.

Intrudalert Receiver Schematic

A Particle Photon (1) measures the Unix time difference between sensor triggers and determines whether or not someone entered or exited the store. It also provides the real time data for internet connected devices. No components are connected to the Photon, as it is only monitoring triggers from the measuring Photon and doing analysis on it.

Code

Intrudalert Measuring Code

C/C++
bool alertedin;
bool alertedout;
void alertin();
void alertout();

// PIR motion detection is running off interrupt functions, which once triggered
// will run either "alertout" or "alertin" functions. Pins D1 and D2 were
// selected as signal inputs from the PIR sensors.
void setup() {
    pinMode(D1, INPUT);
    pinMode(D2, INPUT);
    attachInterrupt(D1, alertout, RISING);
    attachInterrupt(D2, alertin, RISING);
    alertedin = false;
    alertedout = false;
}

// publishes an event to Particle Console when either the outside or
// inside PIR sensor is triggered
void loop() {
    if (alertedout == true) {
        Particle.publish("MotionOut",String(Time.now()),21600,PUBLIC);
            alertedout = false;
    }
    if (alertedin == true) {
          Particle.publish("MotionIn",String(Time.now()),21600,PUBLIC);
            alertedin = false;
    }
}

// sets booleans to true to tigger publish event in running loop
void alertout() {
    alertedout = true;
}

void alertin() {
    alertedin = true;
}

Intrudalert Receiver Code

C/C++
int outtime;
int intime;
int diff;
int i;
bool out;
bool in;

// subscribes the receiver Photon to the published events from the
// mesauring Photon. In the last arguement for the subscribe function, enter
// the device ID from the publishing Photon.
void setup() {

    Particle.subscribe("MotionOut", a,"ID from Publishing Photon");
    Particle.subscribe("MotionIn", b,"ID from Publishing Photon");
    out = false;
    in = false;
    i = 0;
}
// converts Unix time data from subscribe functions to an integer value
void a(const char *event, const char *data) {
    outtime = atoi(data);
      out = true;
}

void b(const char *event, const char *data) {
    intime = atoi(data);
      in = true;
}

// calculates whether the set of triggers was a person entering or exiting.
// Publishes activity to Particle Console
void loop(){
  if (out && in) {
    diff = outtime - intime;
      if (diff > 0) {
        i--;
      } else {
        i++;
      }
    Particle.publish("Count",String(i),21600,PUBLIC);
    out = false;
    in = false;
  }
}

Credits

Cameron Palkowski

Cameron Palkowski

1 project • 1 follower
Robert Cook

Robert Cook

0 projects • 1 follower

Comments

Add projectSign up / Login