summaryrefslogtreecommitdiff
path: root/drivers/dht/dht.py
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2022-09-06 13:49:10 +1000
committerJim Mussared <jim.mussared@gmail.com>2022-09-08 11:27:05 +1000
commit24678fe452e9c0d0b96575424f81fb4a5f5f4302 (patch)
treebb1a3dce7accd6f31477ea759d278dbdfbd8a57b /drivers/dht/dht.py
parentd84c6ef0e8dd363881d80b2d8fb03447cc349830 (diff)
drivers: Remove drivers that are now in micropython-lib.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'drivers/dht/dht.py')
-rw-r--r--drivers/dht/dht.py46
1 files changed, 0 insertions, 46 deletions
diff --git a/drivers/dht/dht.py b/drivers/dht/dht.py
deleted file mode 100644
index 411e9a8d2..000000000
--- a/drivers/dht/dht.py
+++ /dev/null
@@ -1,46 +0,0 @@
-# DHT11/DHT22 driver for MicroPython on ESP8266
-# MIT license; Copyright (c) 2016 Damien P. George
-
-import sys
-
-if sys.platform.startswith("esp"):
- from esp import dht_readinto
-elif sys.platform == "mimxrt":
- from mimxrt import dht_readinto
-elif sys.platform == "rp2":
- from rp2 import dht_readinto
-elif sys.platform == "pyboard":
- from pyb import dht_readinto
-else:
- from machine import dht_readinto
-
-
-class DHTBase:
- def __init__(self, pin):
- self.pin = pin
- self.buf = bytearray(5)
-
- def measure(self):
- buf = self.buf
- 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