當前位置: 首頁>>代碼示例>>Python>>正文


Python Adafruit_DHT.DHT11屬性代碼示例

本文整理匯總了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) 
開發者ID:aws-samples,項目名稱:aws-builders-fair-projects,代碼行數:13,代碼來源:moistureHandler.py

示例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 
開發者ID:enesbcs,項目名稱:rpieasy,代碼行數:10,代碼來源:_P005_DHT.py

示例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 
開發者ID:mudpi,項目名稱:mudpi-core,代碼行數:13,代碼來源:humidity_sensor.py

示例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) 
開發者ID:aws-samples,項目名稱:aws-builders-fair-projects,代碼行數:17,代碼來源:temperatureHandler.py


注:本文中的Adafruit_DHT.DHT11屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。