Ejemplo n.º 1
0
canTemperature = True

while True:
	data = ser.readline()
	if(data[1:5] == "DATA"):
		usrNFC = data[55:62]
		print(usrNFC)
		for user in users:
			if (usrNFC in user.tag):
				AddNFCEntry(usrNFC)
				CPrint("An authentificated user has pass his RFID Tag")
				if("1" in getStateAlarm()):
					CPrint("!!!! Requested alarm to shut down")
					modifyAlarm("0")
					grovepi.digitalWrite(buzzer, 0)
					LCD.setAll("Alarme desactivee", "green")
				elif ("0" in getStateAlarm()):
					CPrint("!!!! Requested alarm to turn on in 15 seconds")
					LCD.setAll("L'alarm va s'enclencher dans 15s", "orange")
					time.sleep(15)
					modifyAlarm("1")
					LCD.setAll("Alarme activee", "red")
				time.sleep(2)
	elif(data[1:5] == "NULL"):
		AddNFCEntry("0")
		LCD.setAll("Aucun id associe. Incident enregistre", "red")
	'''

	elif len(data) >= 4:
		if data[0:2] == "49": #Motion PIR
			if "1" in getStateAlarm():
Ejemplo n.º 2
0
while True:
	try:
		if ("1" in getStateAlarm()):
			#Alarm is on
			a = grovepi.digitalRead(alarm)
			i = i + 1
			if (a == 1):
				t = t +1
			if(i > 50):
				t = 0
				i = 0
			if (t > 4):
				t = 0
				#Movement detected
				CPrint("!!!! Movement detected. Waiting 10 sec for desactivating")
				LCD.setAll("Passez votre tag", "purple")
				time.sleep(waitingTime)
				#Is alarm still on ?
				if ("1" in getStateAlarm()):
					#Yes
					CPrint("!!!! Intruder in the building !")
					#grovepi.digitalWrite(buzzer, 1)
					if(debugMode):
						nowDate = time.strftime('%d/%m a %H:%S')
						send.sendSMSToStaff("Alarme declenche a " + nowDate)
					else:
						timeshot = time.time()
						insertMov(alarm, timeshot)
						addTimeshot(timeshot)
						os.kill(int(camera), signal.SIGUSR1)