Andrew WilkersonAustin GrecoMichael Kaufman
Published

Team 5 Room Monitoring Device

A room monitoring system notifies a guard and allows him to respond quickly. The entire system can be monitored by a command room.

BeginnerWork in progress3 hours544
Team 5 Room Monitoring Device

Things used in this project

Hardware components

Argon
Particle Argon
×3
5 mm LED: Red
5 mm LED: Red
×2
5 mm LED: Green
5 mm LED: Green
×1
PTS 645 Series Switch
C&K Switches PTS 645 Series Switch
×2
Limit Switch, 5 A
Limit Switch, 5 A
×1
Buzzer
Buzzer
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
Maker service
IFTTT Maker service
Google Sheets
Google Sheets

Story

Read more

Schematics

Alarm

Schematic for Switch and LED

Guard

Schematic for button, on-board LED, and notification buzzer.

Command

Schematic for button and two LEDs

Code

Door Alarm - Particle 1

C/C++
The door alarm starts in a loop until the switch is closed. Then it publishes the alarm command and turns on the red LED. Finally it subscribes for the reset command from the command unit. When it is published the LED turns off. *NOTE* The way the switch is wired dictates whether the unit should read a LOW or HIGH to register a closed switch.
const int triggerPin = D5; 
int led = D2;
int triggerState = HIGH;

void setup() {
pinMode(led, OUTPUT);
digitalWrite(led, LOW);    

pinMode(triggerPin, INPUT);
}


void loop() {
  triggerState = digitalRead(triggerPin);
   if (triggerState == LOW) {
       Particle.publish("alarm", PRIVATE);
       digitalWrite(led, HIGH);
       Particle.subscribe("reset", reset, MY_DEVICES);
}

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

Guard Unit - Particle 2

C/C++
The guard unit starts subscribed to the alarm command. Once it's received it activates the buzzer and in unit LED. Upon pressing the button the buzzer turns off and the responding command is published. This is sent to the command unit and logged on a Google Sheets document using IFTT. Finally, it will subscribe to the reset command. Once this is recieved the LED will turn off.
int led = D7;
int buzzer = D4;
int state = 0;
const int buttonPin = D2; 
int buttonState = LOW;



void setup() {

pinMode(led, OUTPUT);
digitalWrite(led, LOW);

pinMode(buttonPin, INPUT);

pinMode(buzzer,OUTPUT);
digitalWrite(buzzer, LOW);

Particle.subscribe("alarm", toggleBuzzer, MY_DEVICES);
}

void resetSystem(const char*event, const char*data)
{
    digitalWrite(led, LOW);
    analogWrite(buzzer, 0);
    
    Particle.subscribe("alarm", toggleBuzzer, MY_DEVICES);
}

void toggleBuzzer(const char*event, const char*data)
{

  digitalWrite(led, HIGH);
  delay(250);
  digitalWrite(led, LOW);
  delay(250);
  
  digitalWrite(led, HIGH);
  delay(100);
  digitalWrite(led, LOW);
  delay(100);
  
  analogWrite(buzzer,50);
  delay(500);
  analogWrite(buzzer,0);
  
  delay(250);
  
  analogWrite(buzzer,100);
  delay(250);
  analogWrite(buzzer,0);
  
  digitalWrite(led, HIGH);
  delay(250);
  digitalWrite(led, LOW);
  delay(250);
  
  digitalWrite(led, HIGH);
  delay(100);
  digitalWrite(led, LOW);
  delay(100);
  
  analogWrite(buzzer,50);
  delay(500);
  analogWrite(buzzer,0);
  
  delay(250);
  
  analogWrite(buzzer,100);
  delay(250);
  analogWrite(buzzer,0);
  
  digitalWrite(led, HIGH);
  analogWrite(buzzer,50);
  
  while (buttonState == LOW){
      buttonState = digitalRead(buttonPin);
   if (buttonState == HIGH) {
       analogWrite(buzzer,0);
       Particle.publish("responding", PRIVATE);
   }
   delay(100);
  }

    Particle.subscribe("reset", resetSystem, MY_DEVICES);
}

Command Unit - Particle 3

C/C++
This unit subscribes to the alarm command. Once it recieves the command a red LED lights up and then it subscribes to the responding command. This command lights the green LED. Finally, once the button is pressed the unit publishes the reset command.
int buttonPin = D5;
int respondingLED = D3;
int alarmLED = D4;
int buttonState = LOW;
int alarmState = LOW;
int respondingState = LOW;

void setup() {
pinMode(buttonPin, INPUT);
pinMode(respondingLED, OUTPUT);
pinMode(alarmLED, OUTPUT);

Particle.subscribe("alarm", alarmResponse, MY_DEVICES);
}

void alarmResponse(const char*event, const char*data)
{
    digitalWrite(alarmLED, HIGH);
    Particle.subscribe("responding", respondingled, MY_DEVICES);
}


void respondingled(const char*event, const char*data)
{
    digitalWrite(respondingLED, HIGH);
    while (buttonState == LOW){
      buttonState = digitalRead(buttonPin);
    }
   if (buttonState == HIGH) {
       digitalWrite(respondingLED, LOW);
       digitalWrite(alarmLED, LOW);
       Particle.subscribe("alarm", alarmResponse, MY_DEVICES);
}
}

Credits

Andrew Wilkerson

Andrew Wilkerson

1 project β€’ 0 followers
Austin Greco

Austin Greco

0 projects β€’ 0 followers
Michael Kaufman

Michael Kaufman

0 projects β€’ 0 followers

Comments