Hardware components | ||||||
| × | 3 | ||||
| × | 3 | ||||
| × | 1 | ||||
| × | 4 | ||||
| × | 3 | ||||
| × | 13 | ||||
Software apps and online services | ||||||
| ||||||
| ||||||
|
The project that we created is called the UBM Security System. It is an IOT-based system comprised of three Particle Argons, an ultrasonic sensor, and four LEDs. When an intruder attempts to open the door, the ultrasonic sensor on the rangefinder Argon detects the intruder, turning on two LEDs and sending a message to the receiver Argon. The receiver Argon begins flashing its built-in LED and sends a signal to the alerter Argon to turn on its built-in LED and another LED. The alerter Argon also sends a notification through IFTTT to the user's phone that the sensor has been tripped. Once the notification has been sent, the alerter Argon turns off its built-in LED and sends a message to the receiver Argon to stop flashing its LED. It also sends a message to the rangefinder Argon to turn off its red LED. When the receiver Argon stops flashing its built-in LED it sends a message to the rangefinder Argon to turn off its white LED. Once the rangefinder Argon is able to confirm that both the red and white LEDs have been turned off, indicating that none of the Argons have been tampered with and confirming that all three of them have been able to successfully complete their tasks, it sends a message to the alerter Argon to turn off its external LED. The built-in redundancies and confirmations of the system which are modeled after some of the security features of blockchain technology allow the UBM Security System to keep your belongings safe and lets you know if the intruder tampers with the system.
VideoPictures of Argon CircuitsLink to Number of Triggers channel
/*
* +-----+
* +----------| USB |----------+
* | +-----+ |
* | [ ] RST |
* | [ ] 3V3 |
* | [ ] MD |
* Ground ->| [*] GND |
* | [ ] A0 Li+ [ ] |
* | [ ] A1 EN [ ] |
* | [ ] A2 VUSB [*] |<- Rangefinder VCC
* | [ ] A3 [S] [R] D8 [ ] |
* | [ ] A4 D7 [ ] |
* | [ ] A5 +-------+ D6 [*] |<- Rangefinder Echo
* | [ ] SCK | * | D5 [*] |<- 220 Ohm --- Red LED
* | [ ] MO | Argon | D4 [*] |<- 220 Ohm --- White LED
* | [ ] MI | | D3 [*] |<- Rangefinger Trig
* | [ ] RX +-------+ D2 [*] |<- 220 Ohm --- Green LED
* | [ ] TX SCL [ ] |
* | [ ] NC SDA [ ] |
* | |
* \ [] [______] /
* \_______________________/
*
*/
unsigned long duration;
WiFiSignal sig = WiFi.RSSI();
int U = 101;
// Initialize vital publishing counter
int V = 1;
// Initialize Confirmation Variable 1
int W = 1;
// Initialize Confirmation Variable 2
int X = 0;
// Initialize sensor trip counter
int Y = 1;
// Initialize repeat non-trigger counter
int Z = 1;
// Initialize repeat trigger counter
void setup() {
pinMode(D7, OUTPUT);
// Built-in LED
pinMode(D2, OUTPUT);
// Sensor tripped LED
pinMode(D6, INPUT);
// Echo
pinMode(D3, OUTPUT);
// Trig
pinMode(D4, OUTPUT);
// Confirmation LED 1
pinMode(D5, OUTPUT);
// Confirmation LED 2
delay(5000);
// Delay for 5 seconds before starting to avoid initial
// arbitrary triggers
Particle.subscribe("LED2Off", MainLED, MY_DEVICES);
// Listen for the signal to turn off Confirmation LED 1
Particle.subscribe("LED3Off", FlatLED, MY_DEVICES);
// Listen for the signal to turn off Confirmation LED 2
}
void loop() {
U = U + 1;
// Iterate vital publishing counter
if (U > 100) {
U = 0;
float RSSInum = sig.getStrength();
String RSSI = String(RSSInum);
Particle.publish("RSSI", RSSI, PRIVATE);
}
delay(10);
// Brief pause
digitalWrite(D3, HIGH);
// Activate trigger
delayMicroseconds(10);
// Pulse for 10 microseconds
digitalWrite(D3, LOW);
// Deactivate trigger
duration = pulseIn(D6, HIGH);
// Time the reply
if (duration > 2000) {
// Time from 200 to 16000 ms
Y = Y + 1;
// Iterates every time the device is not triggered
Z = 1;
// Resets constant trigger counter
digitalWrite(D7, HIGH);
// D7 on if far
digitalWrite(D2, LOW);
// D2 off if far
if (Y < 2) {
// If the device has not been triggered the last 2 times it // has checked, it will stop trying to publish the same // data over and over.
String LED = String(X);
// Convert variable to string
Particle.publish("LED", LED, PRIVATE);
// Generates a flatline if sensor is not tripped. // Thingspeak
}
else {
Y = 2;
// Sets Y to 2 to avoid maxing out the device's memory
}
}
else {
digitalWrite(D7, LOW);
// D7 off if close
digitalWrite(D2, HIGH);
// D2 on if close. Green LED
digitalWrite(D4, HIGH);
// D4 on if sensor is tripped. White LED
digitalWrite(D5, HIGH);
// D5 on if sensor is tripped. Red LED
V = 1;
// Reinitialization of Confirmation Variable 1
W = 1;
// Reinitialization of Confirmation Variable 2
Y = 1;
// Resets null counter
Z = Z + 1;
// Iterate consecutive, uniterrupted trip counter
if (Z < 10) {
// If the device has been triggered 10 times without // interruption it will stop trying to publish the same // data over and over
X = X + 1;
// Iterate sensor trip counter
String LED = String(X);
// Convert variable to string
Particle.publish("LED", LED, PRIVATE);
// Publish the value of the LED variable to Thingspeak
Particle.publish("SensorTripped", PRIVATE);
// Sends an alert to the receiver Argon that the sensor // has been tripped
delay(1500);
// Wait for 1.5 seconds to avoid iterating more than once // per sensor trip
}
else {
Z = 10;
// Sets Z to 10 to avoid maxing out the device's memory
}
}
if (V == 0 && W == 0) {
// Send a signal to the alerter Argon that both LEDs are off
Particle.publish("EverythingOff", PRIVATE);
}
}
void MainLED(const char *event, const char *data) {
// Receives signal from the receiver Argon to turn off
// Confirmation LED 1
digitalWrite(D4, LOW);
V = 0;
}
void FlatLED(const char *event, const char *data) {
// Receives signal from the alerter Argon to turn off
// Confirmation LED 2
digitalWrite(D5, LOW);
W = 0;
}
/*
* +-----+
* +----------| USB |----------+
* | +-----+ |
* | [ ] RST |
* | [ ] 3V3 |
* | [ ] MD |
* Ground ->| [*] GND |
* | [ ] A0 Li+ [ ] |
* | [ ] A1 EN [ ] |
* | [ ] A2 VUSB [ ] |
* | [ ] A3 [S] [R] D8 [ ] |
* | [ ] A4 D7 [ ] |
* | [ ] A5 +-------+ D6 [ ] |
* | [ ] SCK | * | D5 [ ] |
* | [ ] MO | Argon | D4 [ ] |
* | [ ] MI | | D3 [ ] |
* | [ ] RX +-------+ D2 [*] |<- Green LED
* | [ ] TX SCL [ ] |
* | [ ] NC SDA [ ] |
* | |
* \ [] [______] /
* \_______________________/
*
*/
int X = 0;
// Intialize On variable to activate IFTTT notification
void setup() {
pinMode(D7, OUTPUT);
// Initialize mode of built-in LED pin
digitalWrite(D7, LOW);
// Start by making sure that the built-in LED is off
pinMode(D2, OUTPUT);
// Initialize mode of the external LED pin
Particle.subscribe("LEDFlashing", LEDON, MY_DEVICES);
// Listen for a signal from the receiver Argon that the LED is // flashing
Particle.subscribe("EverythingOff", LEDOFF, MY_DEVICES);
// Listen for a signal from the rangefinder Argon to turn all the LEDs // off
}
void LEDON(const char *event, const char *data) {
// What to do when the receiver Argon indicates that it is flashing the // LED
digitalWrite(D7, HIGH);
// Turn on the built-in LED
digitalWrite(D2, HIGH);
// Turn on the external LED
X = 1;
// Set X value to 1 to activatve IFTTT notification
String On = String(X);
// Convert the X value to a string
Particle.publish("On", On, PRIVATE);
// Send the X value to IFTTT so it will send a notifcation
delay(5000);
// Wait 5 seconds
Particle.publish("Off", PRIVATE);
// Send a signal to the receiver Argon to stop flashing the LED
delay(5000);
// Wait 5 seconds
Particle.publish("LED3Off", PRIVATE);
// Send a signal to the rangefinder Argon to turn off
// Confirmation LED 2
digitalWrite(D7, LOW);
// Turn off the built-in LED
X = 0; // Reset X value to 0 so another notification can be sent
}
void LEDOFF(const char *event, const char *data) {
// What to do when the rangefinder Argon publishes EverythingOff
delay(5000);
// Wait 5 seconds
digitalWrite(D2, LOW);
// Turns off the external LED
}
/*
* +-----+
* +----------| USB |----------+
* | +-----+ |
* | [ ] RST |
* | [ ] 3V3 |
* | [ ] MD |
* | [ ] GND |
* | [ ] A0 Li+ [ ] |
* | [ ] A1 EN [ ] |
* | [ ] A2 VUSB [ ] |
* | [ ] A3 [S] [R] D8 [ ] |
* | [ ] A4 D7 [ ] |
* | [ ] A5 +-------+ D6 [ ] |
* | [ ] SCK | * | D5 [ ] |
* | [ ] MO | Argon | D4 [ ] |
* | [ ] MI | | D3 [ ] |
* | [ ] RX +-------+ D2 [ ] |
* | [ ] TX SCL [ ] |
* | [ ] NC SDA [ ] |
* | |
* \ [] [______] /
* \_______________________/
*
*
* The built-in LED is the only physical component used with this Argon
*/
int X = 0;
// Initialize flash counter
void setup() {
Particle.subscribe("SensorTripped", Tripped, MY_DEVICES);
// Receive signal from rangefinder Argon that the device has been tripped
Particle.subscribe("Off", LED1Off, MY_DEVICES);
// Receive signal from alerter Argon to turn off the LED
pinMode(D7, OUTPUT);
// Initialize state of pin D7
pinMode(D2, OUTPUT);
}
void Tripped(const char *event, const char *data) {
// What the Argon does when the sensor has been tripped
Particle.publish("LEDFlashing", PRIVATE);
// Sends an alert to the alerter Argon that the LED is flashing
X = 0;
while (X == 0) {
// Flash the LED until told to stop by the alerter Argon
digitalWrite(D7, HIGH);
delay(100);
digitalWrite(D7, LOW);
delay(100);
}
}
void LED1Off(const char *event, const char *data) {
// Stops flashing the LED when told to do so by the alerter Argon
delay(5000);
// Wait 5 seconds
Particle.publish("LED2Off", PRIVATE);
X = 1;
delay(1000);
// Allows enough time for the signal to be sent before resetting the // flash counter
}
Comments