DHTDevice.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:kiota 作者: Morteo 项目源码 文件源码
def read(self):

    d = None
    if self.config['dht_type'] == 11:
      d = dht.DHT22(machine.Pin(self.config["gpio"]))
    else:
      d = dht.DHT11(machine.Pin(self.config["gpio"]))

    try:
      d.measure()
      payload = { 'temperature': str(d.temperature()), "humidity": str(d.humidity()) }
      return payload
    except Exception as e:
      Util.log(self,"DHT type: {}, failed to measure pin: '{}'".format(self.config["dht_type"], self.config["gpio"]))
      import sys
      sys.print_exception(e)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号