本文整理汇总了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
示例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
示例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
示例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()
示例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
###########################################################