Control and manage personnel entering and exiting a specific area to ensure the safety of the area and protect property.
System | Introduction |
---|---|
End User | The employee uses the Keypad to enter the password, and the password is displayed on the LCD screen. If the password is wrong, the buzzer will sound for 0.5 seconds as a reminder and "Incorrect" word will be displayed on the LCD screen. If the password is correct, "Correct" word will be displayed on the LCD screen. |
Administrator | Administrators can monitor the person who enters the password by browsing the real-time image screen through the video streaming service on the web interface. Administrators can also use the on/off input keys of the web interface to sound the buzzer to drive away criminals. |
Software | Version |
---|---|
Arduino IDE | 1.6.5 |
Adafruit_Keypad | 1.3.2 |
Wire | 1.0.0 |
LiquidCrystal_I2C | 1.1.2 |
Python | 2.7 |
- Raspberry Pi 400:
- LCD1602 I2C:
- Keypad: 4*4
- LED:
- Active Buzzer
- Webcam: RAZER KIYO X
- The hardware's built-in Python version is 2.7 with outdated pip and setup packages, preventing software package installations or updates. Many packages now require Python 3.0 or higher, so the built-in mraa library is used for control.
- CGI Python's redirection to another webpage is cumbersome, requiring direct HTML structure printing. The webpage was later moved to a Raspberry Pi 400, with the Linkit 7688 Duo handling only data transmission.
- The latest Arduino IDE version is incompatible with the MediaTek board. Installing a community-provided json and zip file in Arduino IDE version 1.6.5 resolved this issue.
- Due to version constraints, the MQTT WiFi kit couldn't connect to a mobile hotspot. Instead, direct communication between Linkit Smart 7688duo and Pi400 was established for signal transmission.
#include "Adafruit_Keypad.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F,16,2);
const byte ROWS = 4; // ROW count
const byte COLS = 4; // Collumn count
//Define the name of each key on the keyboard
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {5, 6, 7, 8}; //Define the row pin
byte colPins[COLS] = {9, 10, 11, 12}; //Define the column pin
//Initialize the Keypad
Adafruit_Keypad customKeypad = Adafruit_Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS);
void setup() {
pinMode(14, OUTPUT);
digitalWrite(14, LOW);
Serial.begin(9600);
customKeypad.begin();
Serial.println("KeyPad Test...");
lcd.init();
lcd.backlight();
}
void loop() {
// Start detecting the user's keystroke status
customKeypad.tick();
//Determine which key was pressed
while(customKeypad.available()){
keypadEvent e = customKeypad.read();
Serial.print((char)e.bit.KEY);
if(e.bit.EVENT == KEY_JUST_PRESSED) {
Serial.println(" pressed");
char customkey = (char)e.bit.KEY;
lcd.setCursor(0,0);
lcd.print(customkey);
if (customkey != '1') {
digitalWrite(14, HIGH);
delay(1000);
digitalWrite(14, LOW);
delay(1000);
}
//The pressed state is KEY_JUST_PRESSED
} else if (e.bit.EVENT == KEY_JUST_RELEASED) {
Serial.println(" released");
//The released status is KEY_JUST_RELEASED
}
}
delay(10);
}
from flask import Flask, request, render_template,redirect
import RPi.GPIO as GPIO
import time
app = Flask(__name__)
# Define ledPin
ledPin = 14
# Define testOutPin for input 7688 to control active buzzer
testOutPin = 15
# Set ledpin & testOutPin to low at setup
def setup():
GPIO.setmode(GPIO.BCM)
GPIO.setup(ledPin, GPIO.OUT)
GPIO.output(ledPin, GPIO.LOW)
GPIO.setup(testOutPin, GPIO.OUT)
GPIO.output(testOutPin, GPIO.LOW)
# Ouput testOutPin HIGH to let the active buzzer sound
def sound():
GPIO.output(ledPin, GPIO.HIGH) # make ledPin output HIGH level to turn on led
GPIO.output(testOutPin, GPIO.HIGH) # make testOutPin output HIGH to let the active buzzer sound
print ('led,buzzer turned on >>>') # print information on terminal
# Make all pin out LOW to turn off LED & buzzer
def destroy():
GPIO.output(ledPin, GPIO.LOW) # set the ledPin to output LOW
GPIO.output(testOutPin, GPIO.LOW) # set the testOutPin to output LOW
GPIO.cleanup()
@app.route("/")
def hello():
return "Hello, World!"
# Redirect to form html to control buzzer and monitor
@app.route("/test")
def test():
return render_template("flaskform.html")
# Send post to turn on led and let the buzzer sound
@app.route("/blink",methods=["GET","POST"])
def blink():
# Get form value
islight = request.form.get("LED")
if islight == "U":
sound() # sound the buzzer & turn on LED
else:
destroy()
return render_template("flaskform.html")
app.run()
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Any kinds of test</title>
</head>
<body>
<form method='post'action="{{ url_for("blink")}}">
開起led燈泡和峰鳴器 :<br>
<input type="radio" name="LED" value="U">ON<br>
<input type="radio" name="LED" value="OFF">OFF<br>
<input type="submit" value="Submit" />
</form>
<img src="http://192.168.43.205:8080/?action=stream">
</body>
</html>
#include "Adafruit_Keypad.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F,16,2);
const byte ROWS = 4; // ROW count
const byte COLS = 4; // Collumn count
// Define the name of each key on the keyboard
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {5, 6, 7, 8}; //Define the row pin
byte colPins[COLS] = {9, 10, 11, 12}; //Define the column pin
//Initialize Keypad
Adafruit_Keypad customKeypad = Adafruit_Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS);
#define BuzzerPIN 14
#define piPIN 16
// ##############
// ## password ##
// ##############
// Password Length
const int Password_Length = 7;
// Character to hold password input
String Data;
// Password
String Master = "AD123*0";
// Pin connected to lock relay signal
int lockOutput = 11;
// Counter for character entries
byte data_count = 0;
// Character to hold key input
char customKey;
// ##############
void setup() {
// BuzzerPIN
pinMode(BuzzerPIN, OUTPUT);
digitalWrite(BuzzerPIN, LOW);
pinMode(piPIN, INPUT_PULLUP);
Serial.begin(9600);
customKeypad.begin();
lcd.init();
lcd.backlight();
}
void loop() {
// Initialize LCD and print
lcd.setCursor(0, 0);
lcd.print("Enter Password:");
customKeypad.tick();
while (customKeypad.available())
{
// Enter keypress into array and increment counter
keypadEvent e = customKeypad.read();
customKey = (char)e.bit.KEY;
if (e.bit.EVENT == KEY_JUST_RELEASED) {
Data += customKey;
lcd.setCursor(data_count, 1);
lcd.print(Data[data_count]);
data_count++;
break;
}
}
// See if we have reached the password length
if (data_count == Password_Length) {
lcd.clear();
Serial.println("Password: ");
Serial.print(Data);
if (Data == Master) {
// Correct Password
lcd.print("Correct");
// Turn on relay for 5 seconds
// digitalWrite(BuzzerPIN, HIGH);
delay(500);
// digitalWrite(BuzzerPIN, LOW);
}
else {
// Incorrect Password
lcd.print("Incorrect");
digitalWrite(BuzzerPIN, HIGH);
delay(500);
digitalWrite(BuzzerPIN, LOW);
}
// Clear data and LCD display
lcd.clear();
clearData();
}
int piState = digitalRead(piPIN);
Serial.println(piState);
if (piState == HIGH){
digitalWrite(BuzzerPIN, HIGH);
delay(100);
digitalWrite(BuzzerPIN, LOW);
}
else{
digitalWrite(BuzzerPIN, LOW);
}
}
void clearData() {
//Reset data_count
data_count = 0;
//Reset Data
Data ="";
}
Video Demo 1 : webcam
Video Demo 2 : keypad
PDF : pdf
PowerPoint: powerpoint