当前位置: 首页>>代码示例>>Python>>正文


Python onewire.OneWire方法代码示例

本文整理汇总了Python中onewire.OneWire方法的典型用法代码示例。如果您正苦于以下问题:Python onewire.OneWire方法的具体用法?Python onewire.OneWire怎么用?Python onewire.OneWire使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在onewire的用法示例。


在下文中一共展示了onewire.OneWire方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: read_temp

# 需要导入模块: import onewire [as 别名]
# 或者: from onewire import OneWire [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 onewire [as 别名]
# 或者: from onewire import OneWire [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 onewire [as 别名]
# 或者: from onewire import OneWire [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 onewire [as 别名]
# 或者: from onewire import OneWire [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: read_temps

# 需要导入模块: import onewire [as 别名]
# 或者: from onewire import OneWire [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

示例6: __init__

# 需要导入模块: import onewire [as 别名]
# 或者: from onewire import OneWire [as 别名]
def __init__(self, pin):
        self.ow = OneWire(pin)
        # Scan the 1-wire devices, but only keep those which have the
        # correct # first byte in their rom for a DS18x20 device.
        self.roms = [rom for rom in self.ow.scan() if rom[0] == 0x10 or rom[0] == 0x28] 
开发者ID:TPYBoard,项目名称:developmentBoard,代码行数:7,代码来源:ds18x20.py

示例7: __init__

# 需要导入模块: import onewire [as 别名]
# 或者: from onewire import OneWire [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


注:本文中的onewire.OneWire方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。