def RCtime (PiPin):
measurement = 0
# Discharge capacitor
GPIO.setup(PiPin, GPIO.OUT)
GPIO.output(PiPin, GPIO.LOW)
time.sleep(0.1)
GPIO.setup(PiPin, GPIO.IN)
# Count loops until voltage across
# capacitor reads high on GPIO
start = time.time()
while (GPIO.input(PiPin) == GPIO.LOW):
measurement += 1
end = time.time()
# print end - start
# return measurement
return str(end - start)
# Connects the socket
评论列表
文章目录