在我展示代码之前,只是提供一些我正在处理的项目的背景知识。我目前正在开发一个 Python 脚本,该脚本将在 Raspberry Pi 上运行,以监控地下室污水泵的浮子开关。此代码将检查污水泵是否不符合以下两个标准:
我还没有完成其余的代码,但这是我所拥有的:
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.IN)
floatSwitch = GPIO.input(17)
import smtplib
running = True
log = open("sumpPumpLog.txt", "r+")
startTime = time.time()
def elapsedTime():
"""This function checks how much time
has elapsed since the timer has started"""
endtime = time.time()
elapsed = endtime - starttime
return elapsed
def sendEmail(*msg):
"""This function sends an email to selected recipients with a custom
message as well as the log file …Run Code Online (Sandbox Code Playgroud)