diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2017-05-12 17:57:23 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2017-05-12 17:57:23 +0300 |
commit | e9308c189af388525becbcd42b81ea6d37738135 (patch) | |
tree | 9976c0b87b77e06ae40c52443f2c0d1e0acce7ad /esp8266/scripts/dht.py | |
parent | 5f7ce2a1ca65840ef95d0c044088bc38453b7471 (diff) | |
download | micropython-e9308c189af388525becbcd42b81ea6d37738135.tar.gz micropython-e9308c189af388525becbcd42b81ea6d37738135.zip |
esp8266/scripts: Move drivers/modules to modules/ (frozen bytecode).
Diffstat (limited to 'esp8266/scripts/dht.py')
-rw-r--r-- | esp8266/scripts/dht.py | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/esp8266/scripts/dht.py b/esp8266/scripts/dht.py deleted file mode 100644 index 9a69e7e07e..0000000000 --- a/esp8266/scripts/dht.py +++ /dev/null @@ -1,32 +0,0 @@ -# DHT11/DHT22 driver for MicroPython on ESP8266 -# MIT license; Copyright (c) 2016 Damien P. George - -import esp - -class DHTBase: - def __init__(self, pin): - self.pin = pin - self.buf = bytearray(5) - - 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") - -class DHT11(DHTBase): - def humidity(self): - return self.buf[0] - - def temperature(self): - return self.buf[2] - -class DHT22(DHTBase): - def humidity(self): - return (self.buf[0] << 8 | self.buf[1]) * 0.1 - - def temperature(self): - t = ((self.buf[2] & 0x7f) << 8 | self.buf[3]) * 0.1 - if self.buf[2] & 0x80: - t = -t - return t |