Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mcauser/micropython-dht12
MicroPython driver for the Aosong DHT12 temperature and humidity sensor
https://github.com/mcauser/micropython-dht12
dht dht12 humidity micropython temperature
Last synced: 2 months ago
JSON representation
MicroPython driver for the Aosong DHT12 temperature and humidity sensor
- Host: GitHub
- URL: https://github.com/mcauser/micropython-dht12
- Owner: mcauser
- License: mit
- Created: 2016-09-26T06:46:15.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2024-02-16T15:53:11.000Z (4 months ago)
- Last Synced: 2024-04-16T23:02:48.721Z (2 months ago)
- Topics: dht, dht12, humidity, micropython, temperature
- Language: Python
- Homepage:
- Size: 912 KB
- Stars: 15
- Watchers: 5
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Lists
- awesome-micropython - micropython-dht12 - Aosong DHT12 temperature and humidity sensor, I2C interface. (Libraries / Sensors)
- awesome-mpython - micropython-dht12 - Aosong DHT12 temperature and humidity sensor, I2C interface. (精选驱动库 / 传感器)
README
# MicroPython DHT12 I2C
A MicroPython library for interfacing with an Aosong DHT12 temperature and humidity sensor over I2C.
This library focuses on using the I2C interface. The sensor also supports a 1-wire interface, available when pin 4 is connected to GND.
![demo](docs/DHT12.jpg)
#### Examples
Basic measurement
```python
import dht12
from machine import I2C, Pin
i2c = I2C(scl=Pin(5), sda=Pin(4))
sensor = dht12.DHT12(i2c)
sensor.measure()
print(sensor.temperature())
print(sensor.humidity())
```Continuous measurement
```python
import time
import dht12
from machine import I2C, Pin
i2c = I2C(scl=Pin(5), sda=Pin(4))
sensor = dht12.DHT12(i2c)while True:
sensor.measure()
print(sensor.temperature())
print(sensor.humidity())
time.sleep_ms(4000)
```For full documentation see http://micropython-dht12.rtfd.io/.
## License
Licensed under the [MIT License](http://opensource.org/licenses/MIT).