{
  "id": "mcauser/micropython-dht12",
  "name": "micropython-dht12",
  "prettyName": "micropython-dht12",
  "description": "MicroPython driver for the Aosong DHT12 temperature and humidity sensor",
  "version": "",
  "author": "mcauser",
  "license": "MIT",
  "tags": [
    "dht",
    "dht12",
    "humidity",
    "micropython",
    "temperature"
  ],
  "status": "VALID",
  "official": false,
  "source": "https://github.com/mcauser/micropython-dht12",
  "updatedAt": "2025-06-28T07:01:01.703Z",
  "page": "https://checkmim.com/packages/mcauser+micropython-dht12",
  "createdAt": "2025-05-27T04:34:05.472Z",
  "submittedBy": "oliverr",
  "install": {
    "mpremote": "mpremote mip install github:mcauser/micropython-dht12",
    "mip": "import mip; mip.install(\"github:mcauser/micropython-dht12\")"
  },
  "readme": "# MicroPython DHT12 I2C\n\nA MicroPython library for interfacing with an Aosong DHT12 temperature and humidity sensor over I2C.\n\nThis library focuses on using the I2C interface. The sensor also supports a 1-wire interface, available when pin 4 is connected to GND.\n\n![demo](docs/demo.jpg)\n\n\n## Installation\n\nUsing mip via mpremote:\n\n```bash\n$ mpremote mip install github:mcauser/micropython-dht12\n$ mpremote mip install github:mcauser/micropython-dht12/examples\n```\n\nUsing mip directly on a WiFi capable board:\n\n```python\n>>> import mip\n>>> mip.install(\"github:mcauser/micropython-dht12\")\n>>> mip.install(\"github:mcauser/micropython-dht12/examples\")\n```\n\nManual installation:\n\nCopy `src/dht12.py` to the root directory of your device.\n\n\n## Examples\n\n**Basic usage**\n\n```python\nfrom machine import I2C, Pin\nimport dht12\n\ni2c = I2C(0)\nsensor = dht12.DHT12(i2c)\n\nsensor.measure()\nprint(sensor.temperature())\nprint(sensor.humidity())\n```\n\n\n## Methods\n\n### __init__(i2c)\n\nAs with other modern Aosong sensors, this sensor supports an I2C interface and can be found at address 0x5C.\n\n### check()\n\nScans the I2C bus looking for the sensor at it's fixed I2C address 0x5C. Raises a OSError if not found.\n\n### measure()\n\nReads the temperature and humidity from the sensor over the I2C bus and persists for subsequent calls to `temperature()` and `humidity()`.\nReceived bytes contains a checksum to ensure the data is error free, otherwise an Exception is raised.\n\n### temperature()\n\nReturns the temperature in degrees Celsius from the data collected from the last `measure()` call.\n\n### humidity()\n\nGet the relative humidity as a percentage from the data collected from the last `measure()` call.\n\n\n## Parts\n\n* [DHT12 module](https://s.click.aliexpress.com/e/_DClODk9)\n* [DHT12](https://s.click.aliexpress.com/e/_DCP2d1B)\n* [DHT12](https://s.click.aliexpress.com/e/_DeFy39J)\n* [TinyPICO](https://www.tinypico.com/)\n* [WeMos D1 Mini](https://www.aliexpress.com/item/32529101036.html)\n\n\n## Connections\n\nDHT12 | TinyPICO (ESP32)\n----- | ----------------\nVIN   | 3V3\nSDA   | 22\nGND   | GND\nSCL   | 21\n\nDHT12 | Wemos D1 Mini (ESP8266)\n----- | -----------------------\nVIN   | 3V3\nSDA   | GPIO4\nGND   | GND\nSCL   | GPIO5\n\n\n## Links\n\n* [micropython.org](http://micropython.org)\n* [DHT12 datasheet](docs/DHT12.pdf)\n* [TinyPICO Getting Started](https://www.tinypico.com/gettingstarted)\n\n\n## License\n\nLicensed under the [MIT License](http://opensource.org/licenses/MIT).\n\nCopyright (c) 2016 Mike Causer\n"
}