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


Python Adafruit_DHT.DHT22屬性代碼示例

本文整理匯總了Python中Adafruit_DHT.DHT22屬性的典型用法代碼示例。如果您正苦於以下問題:Python Adafruit_DHT.DHT22屬性的具體用法?Python Adafruit_DHT.DHT22怎麽用?Python Adafruit_DHT.DHT22使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在Adafruit_DHT的用法示例。


在下文中一共展示了Adafruit_DHT.DHT22屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: webform_load

# 需要導入模塊: import Adafruit_DHT [as 別名]
# 或者: from Adafruit_DHT import DHT22 [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

示例2: webform_save

# 需要導入模塊: import Adafruit_DHT [as 別名]
# 或者: from Adafruit_DHT import DHT22 [as 別名]
def webform_save(self,params): # process settings post reply
  par = webserver.arg("plugin_005_type",params)
  if par == "":
    par = DHT.DHT22
  self.taskdevicepluginconfig[0] = int(par)
  if (webserver.arg("plugin_005_over",params)=="on"):
   self.timer2s = True
  else:
   self.timer2s = False
  return True 
開發者ID:enesbcs,項目名稱:rpieasy,代碼行數:12,代碼來源:_P005_DHT.py

示例3: init_sensor

# 需要導入模塊: import Adafruit_DHT [as 別名]
# 或者: from Adafruit_DHT import DHT22 [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: __init__

# 需要導入模塊: import Adafruit_DHT [as 別名]
# 或者: from Adafruit_DHT import DHT22 [as 別名]
def __init__(self, connections, logger, params, sensors, actuators):
        """Sets the sensor pin to pud and publishes its current value"""

        self.lastpoll = time.time()

        #Initialise to some time ago (make sure it publishes)
        self.lastPublish = time.time() - 1000

        self.logger = logger
        self.sensorType = params("Sensor")
        self.sensorMode = params("Mode")

        self.sensor = Adafruit_DHT.DHT22
        self.pin = int(params("Pin"))

        self.precissionTemp = int(params("PressionTemp"))
        self.precissionHum = int(params("PressionHum"))
        self.useF = False

        try:
            if (params("Scale") == 'F'):
                self.useF = True
        except ConfigParser.NoOptionError:
            pass

        #Use 1 reading as default
        self.ARRAY_SIZE = 1

        if (self.sensorMode == "Advanced"):
            #Array size of last readings
            self.ARRAY_SIZE = 5

        #Initialize Array
        self.arrHumidity = [None] * self.ARRAY_SIZE
        self.arrTemperature = [None] * self.ARRAY_SIZE

        self.humidity = None
        self.temperature = None

        self.forcePublishInterval = 60

        self.destination = params("Destination")
        self.poll = float(params("Poll"))

        self.publish = connections

        self.logger.info("----------Configuring DHT Sensor: Type='{0}' pin='{1}' poll='{2}' destination='{3}' Initial values: Hum='{4}' Temp='{5}'".format(self.sensorType, self.pin, self.poll,  self.destination, self.humidity, self.temperature))

        self.publishState() 
開發者ID:rkoshak,項目名稱:sensorReporter,代碼行數:51,代碼來源:DHTSensor.py

示例5: read_handler

# 需要導入模塊: import Adafruit_DHT [as 別名]
# 或者: from Adafruit_DHT import DHT22 [as 別名]
def read_handler(vpin):
    # DHT22
    dht22_sensor = Adafruit_DHT.DHT22  # possible sensor modifications .DHT11 .DHT22 .AM2302. Also DHT21 === DHT22
    humidity, temperature = Adafruit_DHT.read_retry(dht22_sensor, GPIO_DHT22_PIN, retries=5, delay_seconds=1)
    Counter.cycle += 1
    # check that values are not False (mean not None)
    if all([humidity, temperature]):
        print('temperature={} humidity={}'.format(temperature, humidity))
        if temperature <= T_CRI_VALUE:
            blynk.set_property(T_VPIN, 'color', T_CRI_COLOR)
            # send notifications not each time but once a minute (6*10 sec)
            if Counter.cycle % 6 == 0:
                blynk.notify(T_CRI_MSG)
                Counter.cycle = 0
        else:
            blynk.set_property(T_VPIN, 'color', T_COLOR)
        blynk.set_property(H_VPIN, 'color', H_COLOR)
        blynk.virtual_write(T_VPIN, temperature)
        blynk.virtual_write(H_VPIN, humidity)
    else:
        print('[ERROR] reading DHT22 sensor data')
        blynk.set_property(T_VPIN, 'color', ERR_COLOR)  # show aka 'disabled' that mean we errors on data read
        blynk.set_property(H_VPIN, 'color', ERR_COLOR)

    # BMP180
    bmp180_sensor = BMP085.BMP085(busnum=1)
    pressure = bmp180_sensor.read_pressure()
    altitude = bmp180_sensor.read_altitude()
    # check that values are not False (mean not None)
    if all([pressure, altitude]):
        print('pressure={} altitude={}'.format(pressure, altitude))
        blynk.set_property(P_VPIN, 'color', P_COLOR)
        blynk.set_property(A_VPIN, 'color', A_COLOR)
        blynk.virtual_write(P_VPIN, pressure / 133.322)  # mmHg  1mmHg = 133.322 Pa
        blynk.virtual_write(A_VPIN, altitude)
    else:
        print('[ERROR] reading BMP180 sensor data')
        blynk.set_property(P_VPIN, 'color', ERR_COLOR)  # show aka 'disabled' that mean we errors on data read
        blynk.set_property(A_VPIN, 'color', ERR_COLOR)


###########################################################
# infinite loop that waits for event
########################################################### 
開發者ID:blynkkk,項目名稱:lib-python,代碼行數:46,代碼來源:01_weather_station_pi3b.py


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