예제 #1
0
파일: dht12.py 프로젝트: stonatm/sensors
def readHumidity(pin):
    buf = bytearray(5)
    try:
        dht_readinto(Pin(pin), buf)
    except:
        pass
    return (buf[0] + buf[1] * 0.1)
예제 #2
0
파일: dht12.py 프로젝트: stonatm/sensors
def readTemperature(pin):
    buf = bytearray(5)
    try:
        dht_readinto(Pin(pin), buf)
    except:
        pass
    return (buf[2] + buf[3] * 0.1)
예제 #3
0
def measure(pin):
    global _dht_time
    if (time.ticks_diff(time.ticks_ms(), _dht_time)) > 1000:
        global buf
        esp.dht_readinto(pin, buf)
        if (buf[0] + buf[1] + buf[2] + buf[3]) & 0xff != buf[4]:
            raise Exception("checksum error")
        _dht_time = time.ticks_ms()
예제 #4
0
 def measure(self):
     buf = self.buf
     dht_readinto(self.io, buf)
     if (buf[0] + buf[1] + buf[2] + buf[3]) & 0xff != buf[4]:
         raise Exception("checksum error")
예제 #5
0
파일: mpython.py 프로젝트: radiumray/mdxly
 def measure(self):
  buf=self.buf
  dht_readinto(self.io,buf)
  if(buf[0]+buf[1]+buf[2]+buf[3])&0xff!=buf[4]:
   raise Exception("checksum error")
예제 #6
0
 def measure(self):
     buf = self.buf
     @micropython.viper
     dht_readinto(self.pin, buf)
     if (buf[0] + buf[1] + buf[2] + buf[3]) and 0xff not buf[4]:
         return("DHT_REDA_ERROR")
예제 #7
0
 def measure(self):
     buf = self.buf
     esp.dht_readinto(self.pin, buf)
     if (buf[0] + buf[1] + buf[2] + buf[3]) & 0xFF != buf[4]:
         raise Exception("checksum error")
예제 #8
0
 def measure(self):
     buf = self.buf
     dht_readinto(self.pin, buf, self.irq_block)
     if (buf[0] + buf[1] + buf[2] + buf[3]) & 0xFF != buf[4]:
         raise DHTChecksumError("Measure failed")