本文整理匯總了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)