From 9d78305854750d631a2c74b3fa77eeadf4616856 Mon Sep 17 00:00:00 2001
From: Guo Wenxue <guowenxue@gmail.com>
Date: Tue, 19 Mar 2019 23:37:43 +0800
Subject: [PATCH] update infinfrared, monitored, sht20, ds18b20 python code

---
 modules/python/sht20.py    |    2 ++
 monitord/monitord.py       |   16 +++++++++-------
 modules/python/ds18b20.py  |    0 
 modules/python/infrared.py |    8 ++++++--
 4 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/modules/python/ds18b20.py b/modules/python/ds18b20.py
old mode 100644
new mode 100755
diff --git a/modules/python/infrared.py b/modules/python/infrared.py
old mode 100644
new mode 100755
index 6ab73b3..55d064a
--- a/modules/python/infrared.py
+++ b/modules/python/infrared.py
@@ -1,8 +1,12 @@
+#!/usr/bin/python
+#-*- coding: utf-8 -*-
+
 import time
 import signal
 import RPi.GPIO as GPIO
 
-INFR_PIN=16
+# I/O Pin connected to Physical PIN#16, BCM code pin number is 20 and wPi pin number is 28
+INFR_PIN=20
 
 def sig_proc(signum, frame):
     print("Catch stop signal and program exit now...")
@@ -13,7 +17,7 @@
  
 def init():
     GPIO.setwarnings(False)
-    GPIO.setmode(GPIO.BOARD)
+    GPIO.setmode(GPIO.BCM)
     GPIO.setup(INFR_PIN, GPIO.IN)
     pass
  
diff --git a/modules/python/sht20.py b/modules/python/sht20.py
old mode 100644
new mode 100755
index a618a19..69ef7bf
--- a/modules/python/sht20.py
+++ b/modules/python/sht20.py
@@ -1,4 +1,6 @@
 #!/usr/bin/python
+#-*- coding: utf-8 -*-
+
 import fcntl
 import time
 import unittest
diff --git a/monitord/monitord.py b/monitord/monitord.py
index ee31791..89b2315 100755
--- a/monitord/monitord.py
+++ b/monitord/monitord.py
@@ -10,17 +10,19 @@
 from pygame.locals import *
 from ftplib import FTP
 
+RELAY_OFF_TIMEOUT=15
+
 ON=1
 OFF=0
 
-# I/O Pin connected to PIN#16, BCM code pin number is 23 and wPi pin number is 4
-infrared_pin=16
+# I/O Pin connected to Physical PIN#16, BCM code pin number is 20 and wPi pin number is 28
+infrared_pin=20
 
-# I/O Pin connected to PIN#12, which can set be PWM mode
+# I/O Pin Not Connected
 buzzer_pin=12
 
-# I/O Pin connected to PIN#18, BCM code pin number is 24 and wPi pin number is 5
-relay_pin=18
+# I/O Pin connected to Physical PIN#40, BCM code pin number is 21 and wPi pin number is 29
+relay_pin=21
 
 capture_times=2
 local_image="rpi_capture.jpg"
@@ -50,7 +52,7 @@
 
   #Raspberry Python GPIO Initialise
   GPIO.setwarnings(False)
-  GPIO.setmode(GPIO.BOARD)
+  GPIO.setmode(GPIO.BCM)
 
   # Initialise infrared GPIO port
   GPIO.setup(infrared_pin, GPIO.IN)
@@ -93,7 +95,7 @@
   #turn_buzzer_on()
 
   turn_relay(ON)
-  signal.alarm(30)
+  signal.alarm(RELAY_OFF_TIMEOUT)
 
   camera = pygame.camera.Camera("/dev/video0",(1024,768))
   camera.start()

--
Gitblit v1.9.1