commit 4002af4998325566baca0457937a925331996a33 Author: filip Date: Wed Jan 12 21:21:24 2022 +0000 first commit 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"}