J'ai installé sur mon Pi un module RFID RC522 qui fonctionne très bien
Mais comme mon PI fonctionne sur batterie, la consommation du module n'est pas négligeable
D'où l'idée de couper l'alimentation du module lorsqu'il n'est pas utiliser
Sauf que si l'on coupe l'alim, à la remise sous tension du module celui-ci ne réponds plus
Qui aurait une solution ?
Code : Tout sélectionner
#!/usr/bin/python3
# -*-coding:Utf-8 -*-
import signal
import time
import sys
import RPi.GPIO as GPIO # pour l'allumage des LEDs
from pirc522 import RFID
run = True
rdr = RFID()
util = rdr.util()
util.debug = True
bonUID = [xxx,xxx,xxx,xxx,xxx] # Badge rond
LEDverte = 15 # LED verte branchee pin 15
LEDrouge = 13 # LED rouge branchee pin 13
GPIO.setwarnings(False)
GPIO.setup(LEDverte,GPIO.OUT)
GPIO.setup(LEDrouge,GPIO.OUT)
def end_read(signal,frame):
global run
print("\nCtrl+C captured, ending read.")
run = False
rdr.cleanup()
sys.exit()
signal.signal(signal.SIGINT, end_read)
print("Starting")
while run:
refus = 0
refus1 = 0
print ("attente")
rdr.wait_for_tag()
print("Tag detected")
(error, data) = rdr.request()
if not error:
print("\nDetected: " + format(data, "02x"))
(error, uid) = rdr.anticoll()
if not error:
print("Card read UID: "+str(uid[0])+","+str(uid[1])+","+str(uid[2])+","+str(uid[3]))
for i in range(0,4):
if uid[i] != bonUID[i]:
refus = refus + 1
#if uid[i] != bonUID1[i]:
#refus1 = refus1 + 1
if (refus == 0) and (refus1 == 0):
GPIO.output(LEDverte,GPIO.HIGH)
print ("led verte allumee")
time.sleep(2)
GPIO.output(LEDverte,GPIO.LOW)
print ('Ok')
else:
GPIO.output(LEDrouge,GPIO.HIGH)
time.sleep(2)
GPIO.output(LEDrouge,GPIO.LOW)
print ('NOk')
time.sleep(1)