edge lab LIVE! starts Tuesday in Munich. Grab a workshop seat and take home the board you build on. Code FRIEND-HACKSTER saves 20%. () Learn more!
Sophie Wang
Published

Pickpockets Beware!

Have you ever traveled abroad and found that you have been a victim of pickpocketing? If you haven't, I have. It's no fun.

BeginnerFull instructions provided925
Pickpockets Beware!

Things used in this project

Hardware components

Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×12
Arduino UNO
Arduino UNO
×1
RFID reader (generic)
×1
Adafruit Break-beam sensor
×1
LED (generic)
LED (generic)
×1
Resistor 100 ohm
Resistor 100 ohm
×1
Tria Technologies TELUS LTE-M IoT Starter Kit
×1

Software apps and online services

Arduino IDE
Arduino IDE
Visual Studio Code Extension for Arduino
Microsoft Visual Studio Code Extension for Arduino
Windows 10 IoT Core
Microsoft Windows 10 IoT Core

Story

Read more

Code

Code for RFID Key Reader and Break-Beam Sensor

C/C++
This snippet of code controls the logic behind the RFID key reader and break-beam sensor, which are connected through an Arduino Uno board.
/* Name: Sophie Wang, Sara Li, Annie Zou, Aaiza Khalid
Project: Pickpocketing Detector 
Date: Feb 17th, 2019

Purpose: To warn users and protect their bags from potential pickpocketing threats 

Outline:
   1. user clips the device onto the zipper of their bag
   2. user puts on the key reader/ ring on their finger 
   3. device continuously checks for potential pickpocketing threats 
   4. if person going into bag does not have ring on - the device will          alert the owner

Testing:
       - tested the distance of the zipper opening that will trigger the           sensor
       - tested the connection between TELUS LTE-M IoT Starter Kit and the          device
       - tested the connectivity between the wires
       - tested the sensitivity of the sensors by using different mediums 
         to break the beam connection

Restrictions:
       - current prototype is too large to carry 
       - should have a better sound system rather than just an LED                 light to warn the user
*/
 
#include "SPI.h"
#include "MFRC522.h"

#define SS_PIN 10
#define RST_PIN 9
#define SP_PIN 8
#define LED_PIN 7
#define BEAM 4

MFRC522 rfid(SS_PIN, RST_PIN);

MFRC522::MIFARE_Key key;

void setup() {
 Serial.begin(9600);
 SPI.begin();
 rfid.PCD_Init();
 pinMode(LED_PIN, OUTPUT);
 pinMode(BEAM, INPUT);
 digitalWrite(LED_PIN, LOW);
}

void loop() {
 digitalWrite(LED_PIN, !digitalRead(BEAM));
 if (!rfid.PICC_IsNewCardPresent() || !rfid.PICC_ReadCardSerial())
   return;

 // Serial.print(F("PICC type: "));
 MFRC522::PICC_Type piccType = rfid.PICC_GetType(rfid.uid.sak);
 // Serial.println(rfid.PICC_GetTypeName(piccType));

 // Check is the PICC of Classic MIFARE type
 if (piccType != MFRC522::PICC_TYPE_MIFARE_MINI &&
   piccType != MFRC522::PICC_TYPE_MIFARE_1K &&
   piccType != MFRC522::PICC_TYPE_MIFARE_4K) {
   Serial.println(F("Your tag is not of type MIFARE Classic."));
   return;
 }

 String strID = "";
 for (byte i = 0; i < 4; i++) {
   strID +=
   (rfid.uid.uidByte[i] < 0x10 ? "0" : "") +
   String(rfid.uid.uidByte[i], HEX) +
   (i!=3 ? ":" : "");
 }
 strID.toUpperCase();

 Serial.print("Tap card key: ");
 Serial.println(strID);

 if (strID == "A0:AE:DD:87") {
   digitalWrite(LED_PIN, LOW);
   delay(5000);
 } else {
   digitalWrite(LED_PIN, HIGH);
 }

 rfid.PICC_HaltA();
 rfid.PCD_StopCrypto1();
}

Credits

Sophie Wang
1 project • 0 followers
Thanks to Miguel Balboa.

Comments