first commit
This commit is contained in:
		
						commit
						4002af4998
					
				
							
								
								
									
										20
									
								
								registrer.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								registrer.py
									
									
									
									
									
										Normal file
									
								
							| @ -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 | ||||
							
								
								
									
										1
									
								
								settings.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								settings.json
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1 @@ | ||||
| {"url": "http://filip-e490.home/stafett/registrer_stafettpinne.php"} | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user