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


Python ds18x20.DS18X20屬性代碼示例

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


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

示例1: read_temp

# 需要導入模塊: import ds18x20 [as 別名]
# 或者: from ds18x20 import DS18X20 [as 別名]
def read_temp():
    # the device is on GPIO12
    dat = machine.Pin(5)

    # create the onewire object
    ds = ds18x20.DS18X20(onewire.OneWire(dat))

    # scan for devices on the bus
    roms = ds.scan()
    # print('found devices:', roms)
    # print('temperature:', end=' ')
    ds.convert_temp()
    time.sleep_ms(750)
    temp = ds.read_temp(roms[0])
    # print(temp)
    return temp 
開發者ID:stlk,項目名稱:micropython,代碼行數:18,代碼來源:temperature.py

示例2: __init__

# 需要導入模塊: import ds18x20 [as 別名]
# 或者: from ds18x20 import DS18X20 [as 別名]
def __init__(self, name, pin, on_change=None):
        import onewire, ds18x20
        gc.collect()
        Device.__init__(self, name, pin,on_change=on_change)
        self.ds = ds18x20.DS18X20(onewire.OneWire(pin))
        self.roms = self.ds.scan()
        self.lasttime = time.ticks_ms()
        self.ds.convert_temp()
        self.temp_list = None
        self.getters[""] = self.value 
開發者ID:ulno,項目名稱:ulnoiot,代碼行數:12,代碼來源:_ht.py

示例3: readDS18x20

# 需要導入模塊: import ds18x20 [as 別名]
# 或者: from ds18x20 import DS18X20 [as 別名]
def readDS18x20():
    from machine import Pin
    import onewire, ds18x20

    OneWirePin = 0

    # the device is on GPIO12
    dat = Pin(OneWirePin)
    # create the onewire object
    ds = ds18x20.DS18X20(onewire.OneWire(dat))
    # scan for devices on the bus
    roms = ds.scan()
    ds.convert_temp()
    time.sleep_ms(750)
    values = []

    for rom in roms:
        values.append(ds.read_temp(rom))

    print(values)
    return values 
開發者ID:phieber,項目名稱:uPython-ESP8266-01-umqtt,代碼行數:23,代碼來源:main.py

示例4: status

# 需要導入模塊: import ds18x20 [as 別名]
# 或者: from ds18x20 import DS18X20 [as 別名]
def status(self):
        ow = onewire.OneWire(Pin(2))
        ds = ds18x20.DS18X20(ow)
        roms = ds.scan()

        if not len(roms):
            print("Nao encontrei um dispositivo onewire.")
            return None

        ds.convert_temp()
        time.sleep_ms(750)

        temp = 0
        for i in range(10):
            for rom in roms:
                temp += ds.read_temp(rom)
        return temp / 10

    # envia a temperatura para o broker 
開發者ID:DjamesSuhanko,項目名稱:MASUGUX,代碼行數:21,代碼來源:goToBed.py

示例5: time_controlled_measure

# 需要導入模塊: import ds18x20 [as 別名]
# 或者: from ds18x20 import DS18X20 [as 別名]
def time_controlled_measure(self):
        newtime = time.ticks_ms()
        if newtime - self.lasttime < 0 or newtime - self.lasttime > DS18X20.MEASURE_DELAY:
            self.temp_list = []
            for rom in self.roms:
                self.temp_list.append(self.ds.read_temp(rom))
            if len(self.temp_list)==1:
                self.temp_list = self.temp_list[0]
            self.ds.convert_temp()
            self.lasttime = newtime 
開發者ID:ulno,項目名稱:ulnoiot,代碼行數:12,代碼來源:_ht.py

示例6: read_temps

# 需要導入模塊: import ds18x20 [as 別名]
# 或者: from ds18x20 import DS18X20 [as 別名]
def read_temps():
    """Read DS18B20's."""
    dat = machine.Pin(PIN_1W)
    ds = ds18x20.DS18X20(onewire.OneWire(dat))

    ds.convert_temp()
    time.sleep_ms(750)

    return {rom_to_hex(rom): ds.read_temp(rom) for rom in ds.scan()} 
開發者ID:aequitas,項目名稱:templogger,代碼行數:11,代碼來源:templog.py

示例7: __init__

# 需要導入模塊: import ds18x20 [as 別名]
# 或者: from ds18x20 import DS18X20 [as 別名]
def __init__(self, pin=12, place='', server='localhost', chipid='', mac=''):
      self.count = 0
      self.sensor = '000'
      self.temp = '85.0'    # the default error temperature of ds18b20
      self.place = place
      self.server = server
      self.chipid = chipid
      self.mac = mac
      try:
          ow = OneWire(Pin(pin))
          self.ds = ds18x20.DS18X20(ow)
          self.roms = self.ds.scan()
          self.present = True
      except:
          self.present = False 
開發者ID:ernitron,項目名稱:uPython-esp8266-httpserver,代碼行數:17,代碼來源:ds18b20.py


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