From 4002af4998325566baca0457937a925331996a33 Mon Sep 17 00:00:00 2001 From: filip Date: Wed, 12 Jan 2022 21:21:24 +0000 Subject: [PATCH] first commit --- registrer.py | 20 ++++++++++++++++++++ settings.json | 1 + 2 files changed, 21 insertions(+) create mode 100644 registrer.py create mode 100644 settings.json diff --git a/registrer.py b/registrer.py new file mode 100644 index 0000000..7797b9f --- /dev/null +++ b/registrer.py @@ -0,0 +1,20 @@ +from mfrc522 import SimpleMFRC522#rfid reader library +from requests import post#make post requests +from RPi import GPIO +import json + +with open('./settings.json') as json_settings:#open json file with settings + settings = json.loads(json_settings.read())#read the json to a python object + +reader = SimpleMFRC522() + +try: + while True: + id, text = reader.read()#read rfid + print(id) + print(text) + post(settings['url'], {'rfid': str(id) + str(text)})#send POST with rfid + #add code to keep a local backup database +except KeyboardInterrupt:#ctrl + c + GPIO.cleanup()#clean up the gpio + raise#exit program diff --git a/settings.json b/settings.json new file mode 100644 index 0000000..c3e64d8 --- /dev/null +++ b/settings.json @@ -0,0 +1 @@ +{"url": "http://filip-e490.home/stafett/registrer_stafettpinne.php"}