GROUP 3: Port-O-Guard

port-o-guard-2

THE Port-O-Guard:

By Group 3: Kamsi, Haaris, Ntokozo and Sujan

Product photo 1

For our project we chose to work on the security system brief. This took us to firstly brainstorming what kind of objects we want to make. We thought of a Lock that keeps laptops shut, Safes and RFID’s as a general concept.

Our mission: To create a client-interactive system that can be used for the security of an object owned by them or their home.

Our brief: We want our product to be able to detect AND alarm a client when their home has been broken into.


Meeting 1 : Brain storming Ideas

In our first meeting got together to brainstorm on what type of security system we want to create for our client. We looked at the idea of creating a lock for your laptop that keeps it from opening until the finger print of the owner was scanned.

mindMap
Brainstorming ideas for the security system.

After brainstorming on this we the came to our conclusion, we wanted to create a security system that can be left inside the home (or any building the user is in). Keys are registered by the home owner using a master card and it is locked and unlocked by a key card.

Meeting 2: Deciding on idea and ordering components

In our second meeting we decided to talk about what we needed to make this system work. We came to write up a list of components we would need using the thought of what we wanted our product to do.

  1. We want a system that will detect so it needed a sensor and a scanner.
  2. We also want a system that will return either visual or audio feedback so we needed either LED’s or a piezo element.
  3. This system also should be portable so it needs to have components that can be placed into a compact space.
  4. We also want this system to send a notification to the user if there is a break in, therefore an antenna is needed to send or receive information from the user.

Using these product traits we were equipped to make our list.

Components we will need:

  • Breadboard
  • Arduino Uno
  • GSM SIM800C Shield
  • HCSR04 Ultrasonic sensor
  • RFID-RC5SS Scanner
  • 9V Battery
  • 3 LED lights
  • Wires

Using these components we aim to successfully create a system that can detect and alarm a user when there is a potential danger in their area.

Storyboard

Above is our storyboard; it depicts a client getting into his home and scanning his key card on his port-o-guard and a villain breaking in without a key card and suffering the consequences of the police and the user being alarmed.

We then decided who should focus on what in our group and gave each other main jobs to take care of.

Task List:

  1. Brainstorming and Research – all
  2. Product design and functionality – all
  3. Components assembly – Sujan and Ntokozo
  4. Lo-fi card prototype – Sujan and Kamsi
  5. Storyboard – Kamsi
  6. Pseudo Code – Ntokozo and Sujan
  7. Blog documentation – Haaris and Kamsi
  8. Pictures – Kamsi
  9. Code – Ntokozo and Sujan
  10. Test components – all
  11. Circuit layout and Diagrams – Haaris
  12. CAD Prototyping – Haaris
  13. Testing and debugging – Sujan
  14. Final component assembly – all
  15. Presentation – all
  16. Design blog – all
  17. Maker’s Manual – Sujan

CAD Drawings (High fidelity prototype):

These are the High fidelity CAD sketches of the product, we want to make the system as compact as possible but to also be arranged in the most efficient manner. As you can see above, a majority of our components are shown.

img_5046security box 3c79790d-07a7-40b1-a066-dd6c89b0a8b1img_5090img_5092

◦This also shows what will be inside our security system. It is a CAD drawing that shows an RFID Card and an ultrasound scanner. It also has lights to give feedback to a user when their key card works. The ultrasonic sensor is to detect when someone without a card has broken into the house. The LED lights also act as a source of feedback for the user.

Meeting 3: In our 3rd meeting, once we had all our components we decided to produce designs for the product shape and internal component storage. Ideally for this product, it would be best to make the product as compact as possible, without losing functionality. We decided to have the Arduino either above the breadboard to minimise the width as much as possible. This ensures that the security device won’t stick out from the wall too much, perhaps making it not suit the home decor. Regarding visual feedback of the project, we decided to use a combination of LEDs as a response for;

  1. triggering the ultrasonic device with no card scan.
  2. triggering the ultrasonic device with correct card scan.
  3. triggering the ultrasonic device with incorrect card scan.
  4. scanning with correct card and then new card to add new card

Also regarding the design, since the RFID scanner won’t be visible to the user, on the front face the area should be signified where the card needs to be scanned, so we decided to add a contactless symbol.

Image result for contact less symbol

Meeting 4 : Our 4th meeting consisted of prototyping and testing some functions. We produced a lo-fi prototype using cardboard and tape to get a rough idea of what the product could look like and the space we had to fit everything in.

img_5094

Here is our Low-fi prototype. We chose to make it out of cardboard as it is extremely easy to manipulate and therefore we can correct any errors made. But more importantly we can get a more accurate idea of what goes where in our product. We want our product to be visible to the client because when something is not in sight it is more difficult to use.

The Code:

Below is the full code for the security system:

#include <EEPROM.h>
#include <SPI.h>
#include <MFRC522.h>#include <SoftwareSerial.h>SoftwareSerial mySerial(7,8);#define COMMON_ANODE#ifdef COMMON_ANODE
#define LED_ON LOW
#define LED_OFF HIGH
#else
#define LED_ON HIGH
#define LED_OFF LOW
#endif#define redLed 5
#define greenLed 4
#define blueLed 6#define wipeB 3

#define trigPin 1
#define echoPin 2

float timeOut = 200 * 60;
int soundVelocity = 340;
float distance;

bool programMode = false; // initialize programming mode to false

uint8_t successRead; // Variable integer to keep if we have Successful Read from Reader

byte storedCard[4]; // Stores an ID read from EEPROM
byte readCard[4]; // Stores scanned ID read from RFID Module
byte masterCard[4]; // Stores master card's ID read from EEPROM

// Create MFRC522 instance.
#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN);

bool sent=false;

///////////////////////////////////////// Setup ///////////////////////////////////
void setup() {
pinMode(redLed, OUTPUT);
pinMode(greenLed, OUTPUT);
pinMode(blueLed, OUTPUT);
pinMode(wipeB, INPUT_PULLUP); // Enable pin's pull up resistor
pinMode(trigPin,OUTPUT);// set trigPin to output mode
pinMode(echoPin,INPUT);

digitalWrite(redLed, LED_OFF); // Make sure led is off
digitalWrite(greenLed, LED_OFF); // Make sure led is off
digitalWrite(blueLed, LED_OFF); // Make sure led is off

//Protocol Configuration
Serial.begin(9600);
mySerial.begin(9600);
mySerial.println("AT+IPR=9600");// Initialize serial communications with PC
SPI.begin(); // MFRC522 Hardware uses SPI protocol
mfrc522.PCD_Init(); // Initialize MFRC522 Hardware

//If you set Antenna Gain to Max it will increase reading distance
mfrc522.PCD_SetAntennaGain(mfrc522.RxGain_max);

ShowReaderDetails(); // Show details of PCD - MFRC522 Card Reader details

//Wipe Code - If the Button (wipeB) Pressed while setup run (powered on) it wipes EEPROM
if (digitalRead(wipeB) == LOW) { // when button pressed pin should get low, button connected to ground
digitalWrite(redLed, LED_ON); // Red Led stays on to inform user we are going to wipe
Serial.println(F("Wipe Button Pressed"));
Serial.println(F("You have 10 seconds to Cancel"));
Serial.println(F("This will be remove all records and cannot be undone"));
bool buttonState = monitorWipeButton(10000); // Give user enough time to cancel operation
if (buttonState == true && digitalRead(wipeB) == LOW) { // If button still be pressed, wipe EEPROM
Serial.println(F("Starting Wiping EEPROM"));
for (uint16_t x = 0; x < EEPROM.length(); x = x + 1) { //Loop end of EEPROM address
if (EEPROM.read(x) == 0) { //If EEPROM address 0
// do nothing, already clear, go to the next address in order to save time and reduce writes to EEPROM
}
else {
EEPROM.write(x, 0); // if not write 0 to clear, it takes 3.3mS
}
}
Serial.println(F("EEPROM Successfully Wiped"));
digitalWrite(redLed, LED_OFF); // visualize a successful wipe
delay(200);
digitalWrite(redLed, LED_ON);
delay(200);
digitalWrite(redLed, LED_OFF);
delay(200);
digitalWrite(redLed, LED_ON);
delay(200);
digitalWrite(redLed, LED_OFF);
}
else {
Serial.println(F("Wiping Cancelled")); // Show some feedback that the wipe button did not pressed for 15 seconds
digitalWrite(redLed, LED_OFF);
}
}
// Check if master card defined, if not let user choose a master card
// This also useful to just redefine the Master Card
// You can keep other EEPROM records just write other than 143 to EEPROM address 1
// EEPROM address 1 should hold magical number which is '143'
if (EEPROM.read(1) != 143) {
Serial.println(F("No Master Card Defined"));
Serial.println(F("Scan A PICC to Define as Master Card"));
do {
successRead = getID(); // sets successRead to 1 when we get read from reader otherwise 0
digitalWrite(blueLed, LED_ON); // Visualize Master Card need to be defined
delay(200);
digitalWrite(blueLed, LED_OFF);
delay(200);
}
while (!successRead); // Program will not go further while you not get a successful read
for ( uint8_t j = 0; j < 4; j++ ) { // Loop 4 times
EEPROM.write( 2 + j, readCard[j] ); // Write scanned PICC's UID to EEPROM, start from address 3
}
EEPROM.write(1, 143); // Write to EEPROM we defined Master Card.
Serial.println(F("Master Card Defined"));
}
Serial.println(F("-------------------"));
Serial.println(F("Master Card's UID"));
for ( uint8_t i = 0; i < 4; i++ ) { // Read Master Card's UID from EEPROM
masterCard[i] = EEPROM.read(2 + i); // Write it to masterCard
Serial.print(masterCard[i], HEX);
}
Serial.println("");
Serial.println(F("-------------------"));
Serial.println(F("Everything is ready"));
Serial.println(F("Waiting PICCs to be scanned"));
cycleLeds(); // Everything ready lets give user some feedback by cycling leds
}
///////////////////////////////////////// Main Loop ///////////////////////////////////
void loop () {
distance = ping();
if(distance<20.00&&distance>0.00){
uint32_t now = (uint32_t)millis();
do {
successRead = getID(); // sets successRead to 1 when we get read from reader otherwise 0
// When device is in use if wipe button pressed for 10 seconds initialize Master Card wiping
if (digitalRead(wipeB) == LOW) { // Check if button is pressed
// Visualize normal operation is iterrupted by pressing wipe button Red is like more Warning to user
digitalWrite(redLed, LED_ON); // Make sure led is off
digitalWrite(greenLed, LED_OFF); // Make sure led is off
digitalWrite(blueLed, LED_OFF); // Make sure led is off
// Give some feedback
Serial.println(F("Wipe Button Pressed"));
Serial.println(F("Master Card will be Erased! in 10 seconds"));
bool buttonState = monitorWipeButton(10000); // Give user enough time to cancel operation
if (buttonState == true && digitalRead(wipeB) == LOW) { // If button still be pressed, wipe EEPROM
EEPROM.write(1, 0); // Reset Magic Number.
Serial.println(F("Master Card Erased from device"));
Serial.println(F("Please reset to re-program Master Card"));
while (1);
}
Serial.println(F("Master Card Erase Cancelled"));
}
if (programMode) {
cycleLeds(); // Program Mode cycles through Red Green Blue waiting to read a new card
}
else {
normalModeOn(); // Normal mode, blue Power LED is on, all others are off
}
if(((uint32_t)millis()-now)>=10000){
sendText();
}
}
while (!successRead); //the program will not go further while you are not getting a successful read
if (programMode) {
if ( isMaster(readCard) ) { //When in program mode check First If master card scanned again to exit program mode
Serial.println(F("Master Card Scanned"));
Serial.println(F("Exiting Program Mode"));
Serial.println(F("-----------------------------"));
programMode = false;
delay(500);
return;
}
else {
if ( findID(readCard) ) { // If scanned card is known delete it
Serial.println(F("I know this PICC, removing..."));
deleteID(readCard);
Serial.println("-----------------------------");
Serial.println(F("Scan a PICC to ADD or REMOVE to EEPROM"));
}
else { // If scanned card is not known add it
Serial.println(F("I do not know this PICC, adding..."));
writeID(readCard);
Serial.println(F("-----------------------------"));
Serial.println(F("Scan a PICC to ADD or REMOVE to EEPROM"));
}
}
}
else {
if ( isMaster(readCard)) { // If scanned card's ID matches Master Card's ID - enter program mode
programMode = true;
Serial.println(F("Hello Master - Entered Program Mode"));
uint8_t count = EEPROM.read(0); // Read the first Byte of EEPROM that
Serial.print(F("I have ")); // stores the number of ID's in EEPROM
Serial.print(count);
Serial.print(F(" record(s) on EEPROM"));
Serial.println("");
Serial.println(F("Scan a PICC to ADD or REMOVE to EEPROM"));
Serial.println(F("Scan Master Card again to Exit Program Mode"));
Serial.println(F("-----------------------------"));
}
else {
if ( findID(readCard) ) { // If not, see if the card is in the EEPROM
Serial.println(F("Welcome, You shall pass"));
granted(300);
delay(5000);// Open the door lock for 300 ms
}
else { // If not, show that the ID was not valid
Serial.println(F("You shall not pass"));
denied();
}
}
}
}
}

///////////////////////////////////////// Access Granted ///////////////////////////////////
void granted ( uint16_t setDelay) {
digitalWrite(blueLed, LED_OFF); // Turn off blue LED
digitalWrite(redLed, LED_OFF); // Turn off red LED
digitalWrite(greenLed, LED_ON); // Turn on green LED
delay(1000); // Hold green LED on for a second
}

///////////////////////////////////////// Access Denied ///////////////////////////////////
void denied() {
digitalWrite(greenLed, LED_OFF); // Make sure green LED is off
digitalWrite(blueLed, LED_OFF); // Make sure blue LED is off
digitalWrite(redLed, LED_ON); // Turn on red LED
delay(1000);
}
///////////////////////////////////////// Get PICC's UID ///////////////////////////////////
uint8_t getID() {
// Getting ready for Reading PICCs
if ( ! mfrc522.PICC_IsNewCardPresent()) { //If a new PICC placed to RFID reader continue
return 0;
}
if ( ! mfrc522.PICC_ReadCardSerial()) { //Since a PICC placed get Serial and continue
return 0;
}
// There are Mifare PICCs which have 4 byte or 7 byte UID care if you use 7 byte PICC
// I think we should assume every PICC as they have 4 byte UID
// Until we support 7 byte PICCs
Serial.println(F("Scanned PICC's UID:"));
for ( uint8_t i = 0; i < 4; i++) { //
readCard[i] = mfrc522.uid.uidByte[i];
Serial.print(readCard[i], HEX);
}
Serial.println("");
mfrc522.PICC_HaltA(); // Stop reading
return 1;
}

void ShowReaderDetails() {
// Get the MFRC522 software version
byte v = mfrc522.PCD_ReadRegister(mfrc522.VersionReg);
Serial.print(F("MFRC522 Software Version: 0x"));
Serial.print(v, HEX);
if (v == 0x91)
Serial.print(F(" = v1.0"));
else if (v == 0x92)
Serial.print(F(" = v2.0"));
else
Serial.print(F(" (unknown),probably a chinese clone?"));
Serial.println("");
// When 0x00 or 0xFF is returned, communication probably failed
if ((v == 0x00) || (v == 0xFF)) {
Serial.println(F("WARNING: Communication failure, is the MFRC522 properly connected?"));
Serial.println(F("SYSTEM HALTED: Check connections."));
// Visualize system is halted
digitalWrite(greenLed, LED_OFF); // Make sure green LED is off
digitalWrite(blueLed, LED_OFF); // Make sure blue LED is off
digitalWrite(redLed, LED_ON); // Turn on red LED
while (true); // do not go further
}
}

///////////////////////////////////////// Cycle Leds (Program Mode) ///////////////////////////////////
void cycleLeds() {
digitalWrite(redLed, LED_OFF); // Make sure red LED is off
digitalWrite(greenLed, LED_ON); // Make sure green LED is on
digitalWrite(blueLed, LED_OFF); // Make sure blue LED is off
delay(200);
digitalWrite(redLed, LED_OFF); // Make sure red LED is off
digitalWrite(greenLed, LED_OFF); // Make sure green LED is off
digitalWrite(blueLed, LED_ON); // Make sure blue LED is on
delay(200);
digitalWrite(redLed, LED_ON); // Make sure red LED is on
digitalWrite(greenLed, LED_OFF); // Make sure green LED is off
digitalWrite(blueLed, LED_OFF); // Make sure blue LED is off
delay(200);
}

//////////////////////////////////////// Normal Mode Led ///////////////////////////////////
void normalModeOn () {
digitalWrite(blueLed, LED_ON); // Blue LED ON and ready to read card
digitalWrite(redLed, LED_OFF); // Make sure Red LED is off
digitalWrite(greenLed, LED_OFF); // Make sure Green LED is off
// Make sure Door is Locked
}

//////////////////////////////////////// Read an ID from EEPROM //////////////////////////////
void readID( uint8_t number ) {
uint8_t start = (number * 4 ) + 2; // Figure out starting position
for ( uint8_t i = 0; i < 4; i++ ) { // Loop 4 times to get the 4 Bytes
storedCard[i] = EEPROM.read(start + i); // Assign values read from EEPROM to array
}
}

///////////////////////////////////////// Add ID to EEPROM ///////////////////////////////////
void writeID( byte a[] ) {
if ( !findID( a ) ) { // Before we write to the EEPROM, check to see if we have seen this card before!
uint8_t num = EEPROM.read(0); // Get the numer of used spaces, position 0 stores the number of ID cards
uint8_t start = ( num * 4 ) + 6; // Figure out where the next slot starts
num++; // Increment the counter by one
EEPROM.write( 0, num ); // Write the new count to the counter
for ( uint8_t j = 0; j < 4; j++ ) { // Loop 4 times
EEPROM.write( start + j, a[j] ); // Write the array values to EEPROM in the right position
}
successWrite();
Serial.println(F("Succesfully added ID record to EEPROM"));
}
else {
failedWrite();
Serial.println(F("Failed! There is something wrong with ID or bad EEPROM"));
}
}

///////////////////////////////////////// Remove ID from EEPROM ///////////////////////////////////
void deleteID( byte a[] ) {
if ( !findID( a ) ) { // Before we delete from the EEPROM, check to see if we have this card!
failedWrite(); // If not
Serial.println(F("Failed! There is something wrong with ID or bad EEPROM"));
}
else {
uint8_t num = EEPROM.read(0); // Get the numer of used spaces, position 0 stores the number of ID cards
uint8_t slot; // Figure out the slot number of the card
uint8_t start; // = ( num * 4 ) + 6; // Figure out where the next slot starts
uint8_t looping; // The number of times the loop repeats
uint8_t j;
uint8_t count = EEPROM.read(0); // Read the first Byte of EEPROM that stores number of cards
slot = findIDSLOT( a ); // Figure out the slot number of the card to delete
start = (slot * 4) + 2;
looping = ((num - slot) * 4);
num--; // Decrement the counter by one
EEPROM.write( 0, num ); // Write the new count to the counter
for ( j = 0; j < looping; j++ ) { // Loop the card shift times
EEPROM.write( start + j, EEPROM.read(start + 4 + j)); // Shift the array values to 4 places earlier in the EEPROM
}
for ( uint8_t k = 0; k < 4; k++ ) { // Shifting loop
EEPROM.write( start + j + k, 0);
}
successDelete();
Serial.println(F("Succesfully removed ID record from EEPROM"));
}
}

///////////////////////////////////////// Check Bytes ///////////////////////////////////
bool checkTwo ( byte a[], byte b[] ) {
for ( uint8_t k = 0; k < 4; k++ ) { // Loop 4 times
if ( a[k] != b[k] ) { // IF a != b then false, because: one fails, all fail
return false;
}
}
return true;
}

///////////////////////////////////////// Find Slot ///////////////////////////////////
uint8_t findIDSLOT( byte find[] ) {
uint8_t count = EEPROM.read(0); // Read the first Byte of EEPROM that
for ( uint8_t i = 1; i <= count; i++ ) { // Loop once for each EEPROM entry
readID(i); // Read an ID from EEPROM, it is stored in storedCard[4]
if ( checkTwo( find, storedCard ) ) { // Check to see if the storedCard read from EEPROM
// is the same as the find[] ID card passed
return i; // The slot number of the card
}
}
}

///////////////////////////////////////// Find ID From EEPROM ///////////////////////////////////
bool findID( byte find[] ) {
uint8_t count = EEPROM.read(0); // Read the first Byte of EEPROM that
for ( uint8_t i = 1; i < count; i++ ) { // Loop once for each EEPROM entry
readID(i); // Read an ID from EEPROM, it is stored in storedCard[4]
if ( checkTwo( find, storedCard ) ) { // Check to see if the storedCard read from EEPROM
return true;
}
else { // If not, return false
}
}
return false;
}

///////////////////////////////////////// Write Success to EEPROM ///////////////////////////////////
// Flashes the green LED 3 times to indicate a successful write to EEPROM
void successWrite() {
digitalWrite(blueLed, LED_OFF); // Make sure blue LED is off
digitalWrite(redLed, LED_OFF); // Make sure red LED is off
digitalWrite(greenLed, LED_OFF); // Make sure green LED is on
delay(200);
digitalWrite(greenLed, LED_ON); // Make sure green LED is on
delay(200);
digitalWrite(greenLed, LED_OFF); // Make sure green LED is off
delay(200);
digitalWrite(greenLed, LED_ON); // Make sure green LED is on
delay(200);
digitalWrite(greenLed, LED_OFF); // Make sure green LED is off
delay(200);
digitalWrite(greenLed, LED_ON); // Make sure green LED is on
delay(200);
}

///////////////////////////////////////// Write Failed to EEPROM ///////////////////////////////////
// Flashes the red LED 3 times to indicate a failed write to EEPROM
void failedWrite() {
digitalWrite(blueLed, LED_OFF); // Make sure blue LED is off
digitalWrite(redLed, LED_OFF); // Make sure red LED is off
digitalWrite(greenLed, LED_OFF); // Make sure green LED is off
delay(200);
digitalWrite(redLed, LED_ON); // Make sure red LED is on
delay(200);
digitalWrite(redLed, LED_OFF); // Make sure red LED is off
delay(200);
digitalWrite(redLed, LED_ON); // Make sure red LED is on
delay(200);
digitalWrite(redLed, LED_OFF); // Make sure red LED is off
delay(200);
digitalWrite(redLed, LED_ON); // Make sure red LED is on
delay(200);
}

///////////////////////////////////////// Success Remove UID From EEPROM ///////////////////////////////////
// Flashes the blue LED 3 times to indicate a success delete to EEPROM
void successDelete() {
digitalWrite(blueLed, LED_OFF); // Make sure blue LED is off
digitalWrite(redLed, LED_OFF); // Make sure red LED is off
digitalWrite(greenLed, LED_OFF); // Make sure green LED is off
delay(200);
digitalWrite(blueLed, LED_ON); // Make sure blue LED is on
delay(200);
digitalWrite(blueLed, LED_OFF); // Make sure blue LED is off
delay(200);
digitalWrite(blueLed, LED_ON); // Make sure blue LED is on
delay(200);
digitalWrite(blueLed, LED_OFF); // Make sure blue LED is off
delay(200);
digitalWrite(blueLed, LED_ON); // Make sure blue LED is on
delay(200);
}

////////////////////// Check readCard IF is masterCard ///////////////////////////////////
// Check to see if the ID passed is the master programing card
bool isMaster( byte test[] ) {
return checkTwo(test, masterCard);
}

bool monitorWipeButton(uint32_t interval) {
uint32_t now = (uint32_t)millis();
while ((uint32_t)millis() - now < interval) {
// check on every half a second
if (((uint32_t)millis() % 500) == 0) {
if (digitalRead(wipeB) != LOW)
return false;
}
}
return true;
}
void updateSerial()
{
delay(500);
while (Serial.available())
{
mySerial.write(Serial.read());//Forward what Serial received to Software Serial Port
}
while(mySerial.available())
{
Serial.write(mySerial.read());//Forward what Software Serial received to Serial Port
}
}

void sendText(){
if(sent==false){
Serial.println("Initializing...");
delay(1000);

mySerial.println("AT"); //Once the handshake test is successful, it will back to OK
updateSerial();

mySerial.println("AT+CMGF=1"); // Configuring TEXT mode
updateSerial();
mySerial.println("AT+CMGS=\"+447909102011\"");//change ZZ with country code and xxxxxxxxxxx with phone number to sms
updateSerial();
mySerial.print("The alarm has been triggered"); //text content
updateSerial();
mySerial.write(26);
sent=true;
delay(10000);
}

}

float getSonar() {
unsigned long pingTime;
float distance;
digitalWrite(trigPin, HIGH); // make trigPin output high level lasting for 10μs to triger HC_SR04,
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
pingTime = pulseIn(echoPin, HIGH, timeOut); // Wait HC-SR04 returning to the high level and measure out this waitting time
distance = (float)pingTime * soundVelocity / 2 / 10000; // calculate the distance according to the time
return distance; // return the distance value
}

int ping(){
delay(500); // Wait 100ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings.
Serial.print("Ping: ");
Serial.print(getSonar()); // Send ping, get distance in cm and print result (0 = outside set distance range)
Serial.println("cm");
return getSonar();
}

The code for the RFID scanner and the ultrasound scanner mainly came from their libraries.

picture-1

As there were no up to date libraries for the sim module, the code was written to use the sim card through AT commands to send text messages. In the code, there is a timer which is activated by something being close enough to the ultrasound scanner. The timer checks for a successful read of an RFID card. If it does not receive this, the module will proceed to send an SMS to the phone number written in the code.


Final Product:

These photos are the exterior of the product, the Design principles we focus on are: Visibility, Constraints and Feedback.

unknown-3unknown-2

Internal Wirings
This image focuses more on the internal wiring of the product. The ledge which we placed the Arduino Uno with the Shield on top of and then the Breadboard underneath.

Visibility: The principle is that the more visible an element is, the more likely users would know what to do when they see a certain element. Very much like the oyster card tap point:

yellow-reader-small_rdax_400x200

We wanted to make the functions clear to the user from the outside of the product by leaving holes where the Ultrasonic sensor is and  by painting a familiar scan icon where the key card would be placed. The RFID scanner location is highlighted by that icon painted on the side. This will inform users of where they would need to place the key card in order to turn the alarm setting off.

Constraints: This principle focuses on limiting the range of interactions required by the user, in turn ensuring they use it effectively. We have used this principle in our system by only requiring they scan the key card either before or after they walk past the Ultrasonic sensor in order to prevent the alarm/notification going off.

Feedback: A product has to be able to let the user know something is being done or has been done. The way Port-O-guard does this is by giving LED light feedback:

red-green-normal-vision

Simple as green for a successful scan and red for a denied scan and there is an extra blue light to indicate that the system is on and functioning. Another feedback element we have is the Ultrasonic sensor and antenna duo. The scanner picks up on who walks into the house (or breaks in) and there is a 10 second delay before it sends an alarm to the user (the owner of the home). This alarm would be a notification sent to the owner informing them that their home has been broken into, the client can then take action from there.


Security system: User Manual

The alarm system

The alarm system comprises a control unit of just two buttons, one for resetting the system and the other for clearing registered data. The security houses a pp9 9volts battery and other components. The components include ultrasonic distance detector (HC-SR04), which is used to detect the movement of the door. This detector is located at the front-facing surface. SIM800C is integrated to send alert message directly from the microcontroller to the phone and RFID system control access over alarm. The security also consists of 3 coloured LEDs for user feedback.

Placement of security box?

This security is unique as it is situated inside the house. This security uses RFID system. However, it isn’t used to control the doors! It can be directly stocked on to the door frame inside the house.

How does it work? How to use it?

  1. The ultrasonic soundwave detects the opening of the door from the inside of the house.
  2. The correct RFID card then must be tapped to the RFID sensor placed inside the security box under (user-defined interval).
  3. If the person fails to tap the RFID card to the RFID sensor, then the alert message is sent to the owner of the house.

Setting up the security box

The phone number for the alert message – work in progress (possible result include; the use of numbered keypad)

Resetting the system – blue button on the box.

Clearing all the data from the system – red button on the box.

Defining the master card – Press the rest button then tap the card to define it as master card. Red and green light binks if the process is successful

Registering/Erasing any RFID card – Tap the master card to the security box. The red, green and blue led will then start to blink to signify the user that the system is ready to either erase or register the card. The system then iterates to checks if the card is registered to the system or not. If the card is already registered in the system, then the card is removed, and if the card is not found in the system then it is registered. Red led blinks twice to signify that the card is successfully erased and green led blinks twice to signify that the card is successfully registered.

Future improvements:

A list of things we could improve for optimal use:

  • More compact design: The system has to be able to fit on a door frame. The internal positioning of components could be optimised to allow everything to fit in overall smaller dimensions.
  • Camera feedback: Sometimes it may not be a break in, we would have loved to add a small camera that is also connected to the phone of the client.

 

Leave a Reply