本文整理汇总了Python中Adafruit_DHT.DHT11属性的典型用法代码示例。如果您正苦于以下问题:Python Adafruit_DHT.DHT11属性的具体用法?Python Adafruit_DHT.DHT11怎么用?Python Adafruit_DHT.DHT11使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类Adafruit_DHT
的用法示例。
在下文中一共展示了Adafruit_DHT.DHT11属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: collect_temperature
# 需要导入模块: import Adafruit_DHT [as 别名]
# 或者: from Adafruit_DHT import DHT11 [as 别名]
def collect_temperature():
humidity, temperature = Adafruit_DHT.read_retry(sensor_temperature, channel_temperature)
logger.info("humidity: {} temperature: {}".format(humidity, temperature))
if humidity is not None and temperature is not None:
return humidity, temperature
logger.error("Falha ao ler dados do DHT11")
return 0, 0
#GPIO.add_event_detect(channel, GPIO.BOTH)
#GPIO.add_event_callback(channel, collect_moisture)
示例2: webform_load
# 需要导入模块: import Adafruit_DHT [as 别名]
# 或者: from Adafruit_DHT import DHT11 [as 别名]
def webform_load(self): # create html page for settings
choice1 = self.taskdevicepluginconfig[0]
options = ["DHT11","DHT22/AM2302"]
optionvalues = [DHT.DHT11,DHT.DHT22]
webserver.addFormSelector("Sensor type","plugin_005_type",2,options,optionvalues,None,int(choice1))
webserver.addFormCheckBox("Oversampling","plugin_005_over",self.timer2s)
webserver.addFormNote("Strongly recommended to enable oversampling for reliable readings!")
return True
示例3: init_sensor
# 需要导入模块: import Adafruit_DHT [as 别名]
# 或者: from Adafruit_DHT import DHT11 [as 别名]
def init_sensor(self):
#Initialize the sensor here (i.e. set pin mode, get addresses, etc) this gets called by the worker
sensor_types = { '11': Adafruit_DHT.DHT11,
'22': Adafruit_DHT.DHT22,
'2302': Adafruit_DHT.AM2302 }
if self.type in sensor_types:
self.sensor = sensor_types[self.type]
else:
print('Sensor Model Error: Defaulting to DHT11')
self.sensor = Adafruit_DHT.DHT11
return
示例4: collect_moisture
# 需要导入模块: import Adafruit_DHT [as 别名]
# 或者: from Adafruit_DHT import DHT11 [as 别名]
def collect_moisture(channel):
# Efetua a leitura do sensor
umid, temp = 0,0
#umid, temp = Adafruit_DHT.read_retry(sensor, 4)
# Caso leitura esteja ok, mostra os valores na tela
if umid is not None and temp is not None:
print ("Temperatura = {0:0.1f} Umidade = {1:0.1f}n").format(temp, umid)
print ("Aguarda 5 segundos para efetuar nova leitura...n")
publishTemperature(temp, umid)
else:
# Mensagem de erro de comunicacao com o sensor
print("Falha ao ler dados do DHT11 !!!")
#GPIO.add_event_detect(channel, GPIO.BOTH)
#GPIO.add_event_callback(channel, collect_moisture)