initial commit
This commit is contained in:
5
reader_data/sarah/data.csv
Executable file
5
reader_data/sarah/data.csv
Executable file
@@ -0,0 +1,5 @@
|
||||
uid,matrikelnummer,name,expire
|
||||
0x40x1f0x440x120x950x540x80,11806418,mike,2033-08-28
|
||||
0x40x320x450xa0x350x4b0x80,11770981,smartie,2033-05-28
|
||||
0x40x670xd0x320x500x380x80,01525520,flix,2033-05-28
|
||||
0x40x4c0x800x320x500x380x80,01326142,pet,2033-05-28
|
||||
|
39
reader_data/sarah/log.csv
Normal file
39
reader_data/sarah/log.csv
Normal file
@@ -0,0 +1,39 @@
|
||||
name,datum
|
||||
|
||||
smartie,13/06/2022 21:00:59
|
||||
smartie,13/06/2022 21:01:11
|
||||
smartie,13/06/2022 21:01:16
|
||||
smartie,13/06/2022 21:06:34
|
||||
smartie,13/06/2022 21:06:42
|
||||
smartie,13/06/2022 21:06:52
|
||||
smartie,13/06/2022 21:06:59
|
||||
smartie,13/06/2022 21:07:07
|
||||
smartie,13/06/2022 21:08:19
|
||||
smartie,13/06/2022 21:08:25
|
||||
smartie,13/06/2022 21:08:33
|
||||
smartie,13/06/2022 21:08:42
|
||||
smartie,13/06/2022 21:09:13
|
||||
smartie,13/06/2022 21:09:23
|
||||
mike,13/06/2022 21:22:39
|
||||
mike,13/06/2022 21:35:26
|
||||
smartie,13/06/2022 21:40:52
|
||||
flix,13/06/2022 21:46:15
|
||||
mike,14/06/2022 10:14:05
|
||||
mike,14/06/2022 10:16:39
|
||||
mike,14/06/2022 10:25:47
|
||||
mike,14/06/2022 12:26:19
|
||||
mike,14/06/2022 12:35:20
|
||||
mike,14/06/2022 13:26:26
|
||||
mike,14/06/2022 13:27:59
|
||||
mike,14/06/2022 13:28:07
|
||||
mike,14/06/2022 13:28:21
|
||||
pet,14/06/2022 13:56:06
|
||||
pet,14/06/2022 14:02:23
|
||||
mike,14/06/2022 15:33:20
|
||||
mike,14/06/2022 16:07:44
|
||||
mike,14/06/2022 16:22:25
|
||||
mike,14/06/2022 16:22:31
|
||||
mike,14/06/2022 17:45:04
|
||||
mike,14/06/2022 18:01:02
|
||||
mike,14/06/2022 18:05:22
|
||||
flix,14/06/2022 19:09:29
|
||||
|
1153
reader_data/sarah/logs/20220614_debug_log.csv
Normal file
1153
reader_data/sarah/logs/20220614_debug_log.csv
Normal file
File diff suppressed because it is too large
Load Diff
205
reader_data/sarah/logs/20220614_entrance_log.csv
Normal file
205
reader_data/sarah/logs/20220614_entrance_log.csv
Normal file
@@ -0,0 +1,205 @@
|
||||
pet,14/06/2022 21:30:46
|
||||
pet,14/06/2022 21:30:51
|
||||
pet,14/06/2022 21:34:09
|
||||
pet,14/06/2022 21:34:10
|
||||
pet,14/06/2022 21:34:11
|
||||
pet,14/06/2022 21:34:12
|
||||
pet,14/06/2022 21:34:13
|
||||
pet,14/06/2022 21:34:14
|
||||
pet,14/06/2022 21:34:15
|
||||
pet,14/06/2022 21:34:16
|
||||
pet,14/06/2022 21:34:18
|
||||
pet,14/06/2022 21:34:19
|
||||
pet,14/06/2022 21:34:20
|
||||
pet,14/06/2022 21:34:21
|
||||
pet,14/06/2022 21:34:22
|
||||
pet,14/06/2022 21:34:23
|
||||
pet,14/06/2022 21:34:24
|
||||
pet,14/06/2022 21:34:25
|
||||
pet,14/06/2022 21:34:26
|
||||
pet,14/06/2022 21:34:27
|
||||
pet,14/06/2022 21:34:28
|
||||
pet,14/06/2022 21:34:29
|
||||
pet,14/06/2022 21:34:30
|
||||
pet,14/06/2022 21:34:31
|
||||
pet,14/06/2022 21:34:32
|
||||
pet,14/06/2022 21:34:34
|
||||
pet,14/06/2022 21:34:35
|
||||
pet,14/06/2022 21:34:36
|
||||
pet,14/06/2022 21:34:37
|
||||
pet,14/06/2022 21:34:38
|
||||
pet,14/06/2022 21:34:39
|
||||
pet,14/06/2022 21:34:40
|
||||
pet,14/06/2022 21:34:41
|
||||
pet,14/06/2022 21:34:42
|
||||
pet,14/06/2022 21:34:43
|
||||
pet,14/06/2022 21:34:44
|
||||
pet,14/06/2022 21:34:45
|
||||
pet,14/06/2022 21:34:46
|
||||
pet,14/06/2022 21:34:47
|
||||
pet,14/06/2022 21:34:48
|
||||
pet,14/06/2022 21:34:50
|
||||
pet,14/06/2022 21:34:51
|
||||
pet,14/06/2022 21:34:52
|
||||
pet,14/06/2022 21:34:53
|
||||
pet,14/06/2022 21:34:54
|
||||
pet,14/06/2022 21:34:55
|
||||
pet,14/06/2022 21:34:56
|
||||
pet,14/06/2022 21:34:57
|
||||
pet,14/06/2022 21:34:58
|
||||
pet,14/06/2022 21:34:59
|
||||
pet,14/06/2022 21:35:00
|
||||
pet,14/06/2022 21:35:01
|
||||
pet,14/06/2022 21:35:02
|
||||
pet,14/06/2022 21:35:03
|
||||
pet,14/06/2022 21:35:04
|
||||
pet,14/06/2022 21:35:05
|
||||
pet,14/06/2022 21:35:07
|
||||
pet,14/06/2022 21:35:08
|
||||
pet,14/06/2022 21:35:09
|
||||
pet,14/06/2022 21:35:10
|
||||
pet,14/06/2022 21:35:11
|
||||
pet,14/06/2022 21:35:12
|
||||
pet,14/06/2022 21:35:13
|
||||
pet,14/06/2022 21:35:14
|
||||
pet,14/06/2022 21:35:15
|
||||
pet,14/06/2022 21:35:16
|
||||
pet,14/06/2022 21:35:17
|
||||
pet,14/06/2022 21:35:18
|
||||
pet,14/06/2022 21:35:19
|
||||
pet,14/06/2022 21:35:20
|
||||
pet,14/06/2022 21:35:21
|
||||
pet,14/06/2022 21:35:23
|
||||
pet,14/06/2022 21:35:24
|
||||
pet,14/06/2022 21:35:25
|
||||
pet,14/06/2022 21:35:26
|
||||
pet,14/06/2022 21:35:27
|
||||
pet,14/06/2022 21:35:28
|
||||
pet,14/06/2022 21:35:29
|
||||
pet,14/06/2022 21:35:30
|
||||
pet,14/06/2022 21:35:31
|
||||
pet,14/06/2022 21:35:32
|
||||
pet,14/06/2022 21:35:33
|
||||
pet,14/06/2022 21:35:34
|
||||
pet,14/06/2022 21:35:35
|
||||
pet,14/06/2022 21:35:36
|
||||
pet,14/06/2022 21:35:37
|
||||
pet,14/06/2022 21:35:38
|
||||
pet,14/06/2022 21:35:39
|
||||
pet,14/06/2022 21:35:41
|
||||
pet,14/06/2022 21:35:42
|
||||
pet,14/06/2022 21:35:43
|
||||
pet,14/06/2022 21:35:44
|
||||
pet,14/06/2022 21:35:45
|
||||
pet,14/06/2022 21:35:46
|
||||
pet,14/06/2022 21:35:47
|
||||
pet,14/06/2022 21:35:48
|
||||
pet,14/06/2022 21:35:49
|
||||
pet,14/06/2022 21:35:50
|
||||
pet,14/06/2022 21:35:51
|
||||
pet,14/06/2022 21:35:52
|
||||
pet,14/06/2022 21:35:53
|
||||
pet,14/06/2022 21:35:54
|
||||
pet,14/06/2022 21:35:55
|
||||
pet,14/06/2022 21:35:56
|
||||
pet,14/06/2022 21:35:57
|
||||
pet,14/06/2022 21:35:59
|
||||
pet,14/06/2022 21:36:00
|
||||
pet,14/06/2022 21:36:01
|
||||
pet,14/06/2022 21:36:02
|
||||
pet,14/06/2022 21:36:03
|
||||
pet,14/06/2022 21:36:04
|
||||
pet,14/06/2022 21:36:05
|
||||
pet,14/06/2022 21:36:06
|
||||
pet,14/06/2022 21:36:07
|
||||
pet,14/06/2022 21:36:08
|
||||
pet,14/06/2022 21:36:09
|
||||
pet,14/06/2022 21:36:10
|
||||
pet,14/06/2022 21:36:11
|
||||
pet,14/06/2022 21:36:12
|
||||
pet,14/06/2022 21:36:13
|
||||
pet,14/06/2022 21:36:14
|
||||
pet,14/06/2022 21:36:16
|
||||
pet,14/06/2022 21:36:17
|
||||
pet,14/06/2022 21:36:18
|
||||
pet,14/06/2022 21:36:19
|
||||
pet,14/06/2022 21:36:20
|
||||
pet,14/06/2022 21:36:21
|
||||
pet,14/06/2022 21:36:22
|
||||
pet,14/06/2022 21:36:23
|
||||
pet,14/06/2022 21:36:24
|
||||
pet,14/06/2022 21:36:25
|
||||
pet,14/06/2022 21:36:26
|
||||
pet,14/06/2022 21:36:27
|
||||
pet,14/06/2022 21:36:28
|
||||
pet,14/06/2022 21:36:29
|
||||
pet,14/06/2022 21:36:30
|
||||
pet,14/06/2022 21:36:31
|
||||
pet,14/06/2022 21:36:33
|
||||
pet,14/06/2022 21:36:34
|
||||
pet,14/06/2022 21:36:35
|
||||
pet,14/06/2022 21:36:36
|
||||
pet,14/06/2022 21:36:37
|
||||
pet,14/06/2022 21:36:38
|
||||
pet,14/06/2022 21:36:39
|
||||
pet,14/06/2022 21:36:40
|
||||
pet,14/06/2022 21:36:41
|
||||
pet,14/06/2022 21:36:42
|
||||
pet,14/06/2022 21:36:43
|
||||
pet,14/06/2022 21:36:44
|
||||
pet,14/06/2022 21:36:45
|
||||
pet,14/06/2022 21:36:46
|
||||
pet,14/06/2022 21:36:47
|
||||
pet,14/06/2022 21:36:48
|
||||
pet,14/06/2022 21:36:49
|
||||
pet,14/06/2022 21:36:50
|
||||
pet,14/06/2022 21:36:52
|
||||
pet,14/06/2022 21:36:53
|
||||
pet,14/06/2022 21:36:54
|
||||
pet,14/06/2022 21:36:58
|
||||
pet,14/06/2022 21:36:59
|
||||
pet,14/06/2022 21:37:00
|
||||
pet,14/06/2022 21:37:01
|
||||
pet,14/06/2022 21:38:01
|
||||
pet,14/06/2022 21:38:02
|
||||
pet,14/06/2022 21:38:03
|
||||
pet,14/06/2022 21:38:04
|
||||
pet,14/06/2022 21:38:05
|
||||
pet,14/06/2022 21:38:06
|
||||
pet,14/06/2022 21:38:07
|
||||
pet,14/06/2022 21:38:08
|
||||
pet,14/06/2022 21:38:09
|
||||
pet,14/06/2022 21:38:10
|
||||
pet,14/06/2022 21:38:11
|
||||
pet,14/06/2022 21:38:13
|
||||
pet,14/06/2022 21:38:14
|
||||
pet,14/06/2022 21:38:15
|
||||
pet,14/06/2022 21:38:16
|
||||
pet,14/06/2022 21:38:17
|
||||
pet,14/06/2022 21:38:18
|
||||
pet,14/06/2022 21:38:19
|
||||
pet,14/06/2022 21:38:20
|
||||
pet,14/06/2022 21:38:21
|
||||
pet,14/06/2022 21:38:22
|
||||
pet,14/06/2022 21:38:23
|
||||
pet,14/06/2022 21:41:29
|
||||
pet,14/06/2022 21:41:30
|
||||
pet,14/06/2022 21:41:31
|
||||
pet,14/06/2022 21:41:32
|
||||
pet,14/06/2022 21:41:33
|
||||
pet,14/06/2022 21:41:34
|
||||
pet,14/06/2022 21:41:35
|
||||
pet,14/06/2022 21:41:36
|
||||
pet,14/06/2022 21:41:47
|
||||
pet,14/06/2022 21:41:48
|
||||
pet,14/06/2022 21:41:49
|
||||
pet,14/06/2022 21:41:50
|
||||
pet,14/06/2022 21:41:51
|
||||
pet,14/06/2022 21:41:52
|
||||
pet,14/06/2022 21:41:53
|
||||
pet,14/06/2022 21:41:54
|
||||
pet,14/06/2022 21:41:55
|
||||
pet,14/06/2022 21:41:56
|
||||
pet,14/06/2022 21:41:57
|
||||
pet,14/06/2022 21:41:59
|
||||
pet,14/06/2022 21:42:00
|
||||
|
5
reader_data/sarah/logs/20220615_data_backup.csv
Executable file
5
reader_data/sarah/logs/20220615_data_backup.csv
Executable file
@@ -0,0 +1,5 @@
|
||||
uid,matrikelnummer,name,expire
|
||||
0x40x1f0x440x120x950x540x80,11806418,mike,2033-08-28
|
||||
0x40x320x450xa0x350x4b0x80,11770981,smartie,2033-05-28
|
||||
0x40x670xd0x320x500x380x80,01525520,flix,2033-05-28
|
||||
0x40x4c0x800x320x500x380x80,01326142,pet,2033-05-28
|
||||
|
44
reader_data/sarah/logs/20220615_debug_log.csv
Normal file
44
reader_data/sarah/logs/20220615_debug_log.csv
Normal file
@@ -0,0 +1,44 @@
|
||||
|
||||
15/06/2022 10:33:17, UID:0x40x1f0x440x120x950x540x80, Name:mike, Matrikelnummer:11806418, !EXPIRED! no entry!
|
||||
15/06/2022 10:47:29, UID:0x40x1f0x440x120x950x540x80, Name:mike, Matrikelnummer:11806418, !EXPIRED! no entry!
|
||||
|
||||
15/06/2022 10:48:08: Sarah (Simple Access for RFID Authenticated Homes) reader startup.
|
||||
|
||||
|
||||
15/06/2022 10:48:53, UID:0x40x1f0x440x120x950x540x80, Name:mike, Matrikelnummer:11806418, !OKAY! access granted.
|
||||
15/06/2022 10:49:01, UID:0x40x1f0x440x120x950x540x80, Name:mike, Matrikelnummer:11806418, !OKAY! access granted.
|
||||
15/06/2022 10:49:08, UID:0x40x1f0x440x120x950x540x80, Name:mike, Matrikelnummer:11806418, !OKAY! access granted.
|
||||
15/06/2022 10:49:14, UID:0x40x1f0x440x120x950x540x80, Name:mike, Matrikelnummer:11806418, !OKAY! access granted.
|
||||
15/06/2022 10:49:24, UID:0x40x1f0x440x120x950x540x80, Name:mike, Matrikelnummer:11806418, !OKAY! access granted.
|
||||
15/06/2022 10:49:32, UID:0x40x1f0x440x120x950x540x80, Name:mike, Matrikelnummer:11806418, !OKAY! access granted.
|
||||
15/06/2022 10:49:54, UID:0x40x1f0x440x120x950x540x80, Name:mike, Matrikelnummer:11806418, !OKAY! access granted.
|
||||
15/06/2022 10:59:45, UID:0x40x1f0x440x120x950x540x80, Name:mike, Matrikelnummer:11806418, !OKAY! access granted.
|
||||
|
||||
15/06/2022 13:46:38: Sarah (Simple Access for RFID Authenticated Homes) reader startup.
|
||||
|
||||
|
||||
|
||||
15/06/2022 15:32:09: Sarah (Simple Access for RFID Authenticated Homes) reader startup.
|
||||
|
||||
|
||||
15/06/2022 15:32:28, Manual open via website.
|
||||
|
||||
15/06/2022 15:33:11: Sarah (Simple Access for RFID Authenticated Homes) reader startup.
|
||||
|
||||
|
||||
15/06/2022 15:33:16, Manual open via website.
|
||||
15/06/2022 15:33:27, Manual open via website.
|
||||
15/06/2022 15:33:36, Manual open via website.
|
||||
15/06/2022 15:37:42, Reboot executed via website.
|
||||
|
||||
15/06/2022 15:37:56: Sarah (Simple Access for RFID Authenticated Homes) reader startup.
|
||||
|
||||
|
||||
15/06/2022 15:40:01, Reboot executed via website.
|
||||
|
||||
15/06/2022 15:40:15: Sarah (Simple Access for RFID Authenticated Homes) reader startup.
|
||||
|
||||
|
||||
15/06/2022 15:48:31, UID:0x40x1f0x440x120x950x540x80, Name:mike, Matrikelnummer:11806418, !OKAY! access granted.
|
||||
15/06/2022 16:34:25, UID:0x40x1f0x440x120x950x540x80, Name:mike, Matrikelnummer:11806418, !OKAY! access granted.
|
||||
15/06/2022 16:38:31, UID:0x40x1f0x440x120x950x540x80, Name:mike, Matrikelnummer:11806418, !OKAY! access granted.
|
||||
|
11
reader_data/sarah/logs/20220615_entrance_log.csv
Normal file
11
reader_data/sarah/logs/20220615_entrance_log.csv
Normal file
@@ -0,0 +1,11 @@
|
||||
mike,15/06/2022 10:48:57
|
||||
mike,15/06/2022 10:49:05
|
||||
mike,15/06/2022 10:49:12
|
||||
mike,15/06/2022 10:49:18
|
||||
mike,15/06/2022 10:49:28
|
||||
mike,15/06/2022 10:49:36
|
||||
mike,15/06/2022 10:49:58
|
||||
mike,15/06/2022 10:59:49
|
||||
mike,15/06/2022 15:48:35
|
||||
mike,15/06/2022 16:34:29
|
||||
mike,15/06/2022 16:38:35
|
||||
|
21
reader_data/sarah/sarah_crontab_sytem_functions.py
Normal file
21
reader_data/sarah/sarah_crontab_sytem_functions.py
Normal file
@@ -0,0 +1,21 @@
|
||||
import os
|
||||
from datetime import datetime
|
||||
|
||||
#
|
||||
# this is part of the sarah RFID reader
|
||||
# reader.py if the real file
|
||||
#
|
||||
|
||||
|
||||
|
||||
|
||||
#there is the possibility to restart the raspberry via the website
|
||||
#the webserver saves an emtpy file (manual_restart_machine_request_set) to the disk
|
||||
#if the file is there, we delete the file and reboot the machine
|
||||
if os.path.isfile('/home/zutritt/Documents/sarah/system_request_commands/manual_restart_machine_request_set'):
|
||||
os.remove('/home/zutritt/Documents/sarah/system_request_commands/manual_restart_machine_request_set')
|
||||
#if this file exists, there was a door open request made from the browser
|
||||
debug_file = open("/home/zutritt/Documents/sarah/logs/"+datetime.today().strftime('%Y%m%d')+"_debug_log.csv", "a")
|
||||
debug_file.write("\n"+datetime.now().strftime("%d/%m/%Y %H:%M:%S") + ", Reboot executed via website.")
|
||||
debug_file.close()
|
||||
os.system('sudo reboot')
|
||||
20
reader_data/sarah/src/open.py
Normal file
20
reader_data/sarah/src/open.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import RPi.GPIO as GPIO
|
||||
import board
|
||||
import time
|
||||
import busio
|
||||
from digitalio import DigitalInOut, Direction
|
||||
|
||||
|
||||
def main():
|
||||
PIN_DOOR = 6
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
GPIO.setup(PIN_DOOR,GPIO.OUT)
|
||||
GPIO.output(PIN_DOOR,False)
|
||||
while True:
|
||||
time.sleep(1)
|
||||
GPIO.output(PIN_DOOR,True)
|
||||
time.sleep(4)
|
||||
GPIO.output(PIN_DOOR,False)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
76
reader_data/sarah/src/pn532_low_power.py
Normal file
76
reader_data/sarah/src/pn532_low_power.py
Normal file
@@ -0,0 +1,76 @@
|
||||
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
"""
|
||||
This example shows connecting to the PN532 with I2C (requires clock
|
||||
stretching support), SPI, or UART. SPI is best, it uses the most pins but
|
||||
is the most reliable and universally supported. In this example we put the PN532
|
||||
into low power mode and sleep for 1 second in-between trying to read tags.
|
||||
After initialization, try waving various 13.56MHz RFID cards over it!
|
||||
"""
|
||||
|
||||
import time
|
||||
import board
|
||||
import busio
|
||||
import RPi.GPIO as GPIO
|
||||
import pandas as pd
|
||||
|
||||
from digitalio import DigitalInOut
|
||||
|
||||
#
|
||||
# NOTE: pick the import that matches the interface being used
|
||||
#
|
||||
from adafruit_pn532.i2c import PN532_I2C
|
||||
|
||||
# from adafruit_pn532.spi import PN532_SPI
|
||||
# from adafruit_pn532.uart import PN532_UART
|
||||
|
||||
# I2C connection:
|
||||
i2c = busio.I2C(board.SCL, board.SDA)
|
||||
|
||||
# Non-hardware
|
||||
# pn532 = PN532_I2C(i2c, debug=False)
|
||||
|
||||
# With I2C, we recommend connecting RSTPD_N (reset) to a digital pin for manual
|
||||
# harware reset
|
||||
reset_pin = DigitalInOut(board.D6)
|
||||
# On Raspberry Pi, you must also connect a pin to P32 "H_Request" for hardware
|
||||
# wakeup! this means we don't need to do the I2C clock-stretch thing
|
||||
req_pin = DigitalInOut(board.D12)
|
||||
pn532 = PN532_I2C(i2c, debug=False, reset=reset_pin, req=req_pin)
|
||||
|
||||
# SPI connection:
|
||||
# spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
|
||||
# cs_pin = DigitalInOut(board.D5)
|
||||
# pn532 = PN532_SPI(spi, cs_pin, debug=False)
|
||||
|
||||
# UART connection
|
||||
# uart = busio.UART(board.TX, board.RX, baudrate=115200, timeout=0.1)
|
||||
# pn532 = PN532_UART(uart, debug=False)
|
||||
|
||||
ic, ver, rev, support = pn532.firmware_version
|
||||
print("Found PN532 with firmware version: {0}.{1}".format(ver, rev))
|
||||
|
||||
# Configure PN532 to communicate with MiFare cards
|
||||
pn532.SAM_configuration()
|
||||
|
||||
df = pd.read_csv('data.csv')
|
||||
|
||||
#for csv_id in data.loc[:,"ID"]:
|
||||
# if("0432450A354B80" in csv_id):
|
||||
# print("yes")
|
||||
|
||||
t = [df.loc[lambda df: df['ID'] == "0432450A354B80"]]
|
||||
t
|
||||
|
||||
print("Waiting for RFID/NFC card...")
|
||||
|
||||
while True:
|
||||
# Check if a card is available to read
|
||||
uid = pn532.read_passive_target(timeout=0.5)
|
||||
print(".", end="")
|
||||
if uid is not None:
|
||||
print("Found card with UID:", [hex(i) for i in uid])
|
||||
print(uid)
|
||||
pn532.power_down()
|
||||
time.sleep(1.0)
|
||||
60
reader_data/sarah/src/pn532_simpletest.py
Normal file
60
reader_data/sarah/src/pn532_simpletest.py
Normal file
@@ -0,0 +1,60 @@
|
||||
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
"""
|
||||
This example shows connecting to the PN532 with I2C (requires clock
|
||||
stretching support), SPI, or UART. SPI is best, it uses the most pins but
|
||||
is the most reliable and universally supported.
|
||||
After initialization, try waving various 13.56MHz RFID cards over it!
|
||||
"""
|
||||
|
||||
import board
|
||||
import busio
|
||||
from digitalio import DigitalInOut
|
||||
|
||||
#
|
||||
# NOTE: pick the import that matches the interface being used
|
||||
#
|
||||
from adafruit_pn532.i2c import PN532_I2C
|
||||
|
||||
# from adafruit_pn532.spi import PN532_SPI
|
||||
# from adafruit_pn532.uart import PN532_UART
|
||||
|
||||
# I2C connection:
|
||||
i2c = busio.I2C(board.SCL, board.SDA)
|
||||
|
||||
# Non-hardware
|
||||
# pn532 = PN532_I2C(i2c, debug=False)
|
||||
|
||||
# With I2C, we recommend connecting RSTPD_N (reset) to a digital pin for manual
|
||||
# harware reset
|
||||
reset_pin = DigitalInOut(board.D6)
|
||||
# On Raspberry Pi, you must also connect a pin to P32 "H_Request" for hardware
|
||||
# wakeup! this means we don't need to do the I2C clock-stretch thing
|
||||
req_pin = DigitalInOut(board.D12)
|
||||
pn532 = PN532_I2C(i2c, debug=False, reset=reset_pin, req=req_pin)
|
||||
|
||||
# SPI connection:
|
||||
# spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
|
||||
# cs_pin = DigitalInOut(board.D5)
|
||||
# pn532 = PN532_SPI(spi, cs_pin, debug=False)
|
||||
|
||||
# UART connection
|
||||
# uart = busio.UART(board.TX, board.RX, baudrate=115200, timeout=100)
|
||||
# pn532 = PN532_UART(uart, debug=False)
|
||||
|
||||
ic, ver, rev, support = pn532.firmware_version
|
||||
print("Found PN532 with firmware version: {0}.{1}".format(ver, rev))
|
||||
|
||||
# Configure PN532 to communicate with MiFare cards
|
||||
pn532.SAM_configuration()
|
||||
|
||||
print("Waiting for RFID/NFC card...")
|
||||
while True:
|
||||
# Check if a card is available to read
|
||||
uid = pn532.read_passive_target(timeout=0.5)
|
||||
print(".", end="")
|
||||
# Try again if no card is available.
|
||||
if uid is None:
|
||||
continue
|
||||
print("Found card with UID:", uid)#[i for i in uid])
|
||||
142
reader_data/sarah/src/reader.py
Normal file
142
reader_data/sarah/src/reader.py
Normal file
@@ -0,0 +1,142 @@
|
||||
import RPi.GPIO as GPIO
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
import board
|
||||
import busio
|
||||
from digitalio import DigitalInOut, Direction
|
||||
from adafruit_pn532.i2c import PN532_I2C
|
||||
import time
|
||||
from datetime import datetime
|
||||
import os
|
||||
import shutil
|
||||
|
||||
#
|
||||
# This tool was written by Kourosh (aladdin@fet.at) in 2022
|
||||
# and extended by Pet (pet@fet.at) in 6.2022
|
||||
#
|
||||
# It reads the ID from a RFID card and compares it to a stored set of cards
|
||||
# if the card is valid, it pulls a pin HIGH, which in turn opens the door
|
||||
# to the FET lab.
|
||||
#
|
||||
|
||||
def main():
|
||||
|
||||
#create a debug log to print everything that happens into there
|
||||
debug_file = open("/home/zutritt/Documents/sarah/logs/"+datetime.today().strftime('%Y%m%d')+"_debug_log.csv", "a")
|
||||
debug_file.write("\n\n" + datetime.now().strftime("%d/%m/%Y %H:%M:%S") +": Sarah (Simple Access for RFID Authenticated Homes) reader startup. \n\n")
|
||||
debug_file.close()
|
||||
|
||||
|
||||
##set up the hardware
|
||||
i2c = busio.I2C(board.SCL, board.SDA)
|
||||
reset_pin = DigitalInOut(board.D6)
|
||||
req_pin = DigitalInOut(board.D12)
|
||||
pn532 = PN532_I2C(i2c, debug=False, reset=reset_pin, req=req_pin)
|
||||
pn532.SAM_configuration()
|
||||
PIN_DOOR = 6
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
GPIO.output(PIN_DOOR,False)
|
||||
GPIO.setup(4,GPIO.OUT)
|
||||
GPIO.setup(22,GPIO.OUT)
|
||||
GPIO.setup(5,GPIO.OUT)
|
||||
GPIO.setup(26,GPIO.OUT)
|
||||
GPIO.setup(PIN_DOOR,GPIO.OUT)
|
||||
GPIO.output(4,False)
|
||||
GPIO.output(22,False)
|
||||
GPIO.output(26,False)
|
||||
GPIO.output(PIN_DOOR,False)
|
||||
|
||||
#create a backup of the data file
|
||||
shutil.copy('/home/zutritt/Documents/sarah/data.csv', '/home/zutritt/Documents/sarah/logs/' + datetime.today().strftime('%Y%m%d') + '_data_backup.csv')
|
||||
|
||||
#read the data file once. it will be re-read, if we don't know the UID of a read card or the card is expired.
|
||||
#this saves read/write cycles on the SD card
|
||||
data = pd.read_csv(r'/home/zutritt/Documents/sarah/data.csv') #,names=col_names)
|
||||
|
||||
#mail loop
|
||||
while True:
|
||||
|
||||
#try reading a tag
|
||||
time.sleep(0.5)
|
||||
uid = pn532.read_passive_target(timeout=0.5)
|
||||
#print(uid)
|
||||
|
||||
### DEBUG!!!!!
|
||||
#string = "04 4c 80 32 50 38 81" #pet80
|
||||
#uid = bytearray.fromhex(string)
|
||||
### DEBUG END!!!!
|
||||
|
||||
#there is the possibility to open the door via the website
|
||||
#the webserver saves an emtpy file (manual_door_open_request_set) to the disk
|
||||
#if the file is there, we open the door and delete the file afterwards
|
||||
if os.path.isfile('/home/zutritt/Documents/sarah/system_request_commands/manual_door_open_request_set'):
|
||||
#if this file exists, there was a door open request made from the browser
|
||||
GPIO.output(PIN_DOOR,True)
|
||||
time.sleep(4)
|
||||
GPIO.output(PIN_DOOR,False)
|
||||
debug_file = open("/home/zutritt/Documents/sarah/logs/"+datetime.today().strftime('%Y%m%d')+"_debug_log.csv", "a")
|
||||
debug_file.write("\n"+datetime.now().strftime("%d/%m/%Y %H:%M:%S") + ", Manual open via website.")
|
||||
debug_file.close()
|
||||
with open("/home/zutritt/Documents/sarah/logs/"+ datetime.today().strftime('%Y%m%d') +"_entrance_log.csv", "a") as x:
|
||||
x.write("Manual entry via website, " + datetime.now().strftime("%d/%m/%Y %H:%M:%S") + "\n")
|
||||
x.close()
|
||||
|
||||
os.remove('/home/zutritt/Documents/sarah/system_request_commands/manual_door_open_request_set')
|
||||
|
||||
#after reading a tag, we check if any numbers have been read
|
||||
#no numbers mean no tag has been detected
|
||||
if (not isinstance(uid,bytearray)):
|
||||
continue
|
||||
uid = [hex(i) for i in uid]
|
||||
uid = "".join(uid)
|
||||
|
||||
#write to the debug file that we found a tag
|
||||
debug_file = open("/home/zutritt/Documents/sarah/logs/"+datetime.today().strftime('%Y%m%d')+"_debug_log.csv", "a")
|
||||
debug_file.write("\n"+datetime.now().strftime("%d/%m/%Y %H:%M:%S") + ", UID:" + uid)
|
||||
|
||||
#print (uid)
|
||||
#print (list(data["uid"]))
|
||||
|
||||
# check if the card is anywhere in our saved cards
|
||||
if uid in list(data["uid"]):
|
||||
#save the line where he card is in
|
||||
line = data.query("uid == @uid")
|
||||
print(line)
|
||||
expiration_date = datetime.strptime(str(list(line["expire"])[0]), "%Y-%m-%d")
|
||||
|
||||
#check if the card is expired
|
||||
if datetime.now() < expiration_date:
|
||||
|
||||
#open the door if the card is valid
|
||||
GPIO.output(PIN_DOOR,True)
|
||||
time.sleep(4)
|
||||
GPIO.output(PIN_DOOR,False)
|
||||
|
||||
#log the entry to the entrance log and the debug log
|
||||
with open("/home/zutritt/Documents/sarah/logs/"+ datetime.today().strftime('%Y%m%d') +"_entrance_log.csv", "a") as x:
|
||||
debug_file.write(", Name:" + str(list(line["name"])[0]) + ", Matrikelnummer:" + str(list(line["matrikelnummer"])[0]) + ", !OKAY! access granted.")
|
||||
x.write(str(list(line["name"])[0]) + "," + datetime.now().strftime("%d/%m/%Y %H:%M:%S") + "\n")
|
||||
x.close()
|
||||
|
||||
|
||||
else: #card is expired
|
||||
debug_file.write(", Name:" + str(list(line["name"])[0]) + ", Matrikelnummer:" + str(list(line["matrikelnummer"])[0]) + ", !EXPIRED! no entry!")
|
||||
try:
|
||||
data = pd.read_csv(r'/home/zutritt/Documents/sarah/data.csv') #read the file again, in case something has changed
|
||||
debug_file.write(" (data.csv reloaded)")
|
||||
except OSError as e:
|
||||
debug_file.write(", !data.csv reloaded failed!")
|
||||
|
||||
else:#the card is not in the system
|
||||
debug_file.write(", !No known UID! no entry!")
|
||||
try:
|
||||
data = pd.read_csv(r'/home/zutritt/Documents/sarah/data.csv') #read the file again, in case something has changed
|
||||
debug_file.write(" (data.csv reloaded)")
|
||||
except OSError as e:
|
||||
debug_file.write(", !data.csv reloaded failed!")
|
||||
|
||||
GPIO.output(PIN_DOOR,False)
|
||||
debug_file.close()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
3
reader_data/sarah/system_request_commands/info.txt
Normal file
3
reader_data/sarah/system_request_commands/info.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
THIS FOLDRE IS MOSTLY EMPTY!
|
||||
der webserver speichert hier files rein wenn er was requesten will, darum sind die permisisons so komisch
|
||||
15.6.22, pet
|
||||
Reference in New Issue
Block a user