請大家幫忙,因爲我正在嘗試使用覆盆子pi pir傳感器將pir傳感器(它是1或0)收集的數據傳輸到web服務 以及我得到這個錯誤AttributeError:'NoneType'對象沒有屬性'group'
Traceback (most recent call last):
File "pir_5.py", line 54, in <module>
moveHold = float(matches.group(1))
AttributeError: 'NoneType' object has no attribute 'group'
,這是我的代碼
while True :
# Read PIR state
Current_State = GPIO.input(GPIO_PIR)
if Current_State==1 and Previous_State==0:
# PIR is triggered
output = subprocess.check_output(["echo", "18"]);
print " Motion detected!"
# Tell the Pi to run our speech script and speak the words
# motion dtected! - anything after the .sh will be read out.
matches = re.search("Current_State==1 and Previous_State==0", output)
moveHold = float(matches.group(1))
resultm = client.service.retrieveMove(moveHold)
cmd_string = './speech.sh motion detected!'
# now run the command on the Pi.
os.system(cmd_string)
# Record previous state
Previous_State=1
elif Current_State==0 and Previous_State==1:
# PIR has returned to ready state
print " Ready"
Previous_State=0
# Wait for 10 milliseconds
time.sleep(0.01)