{"id":22253877,"url":"https://github.com/mcauser/microbit-dht12","last_synced_at":"2025-03-25T12:26:31.954Z","repository":{"id":150620616,"uuid":"121741510","full_name":"mcauser/microbit-dht12","owner":"mcauser","description":"MicroPython for micro:bit library for the Aosong DHT12 temperature and humidity sensor","archived":false,"fork":false,"pushed_at":"2018-08-07T15:42:56.000Z","size":354,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-30T11:27:50.534Z","etag":null,"topics":["dht","dht12","humidity","microbit","microbit-scripts","micropython","temperature"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mcauser.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-02-16T11:03:13.000Z","updated_at":"2020-04-29T08:09:43.000Z","dependencies_parsed_at":"2023-05-06T09:33:17.176Z","dependency_job_id":null,"html_url":"https://github.com/mcauser/microbit-dht12","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcauser%2Fmicrobit-dht12","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcauser%2Fmicrobit-dht12/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcauser%2Fmicrobit-dht12/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcauser%2Fmicrobit-dht12/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mcauser","download_url":"https://codeload.github.com/mcauser/microbit-dht12/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245460722,"owners_count":20619126,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dht","dht12","humidity","microbit","microbit-scripts","micropython","temperature"],"created_at":"2024-12-03T07:20:40.433Z","updated_at":"2025-03-25T12:26:31.923Z","avatar_url":"https://github.com/mcauser.png","language":"Python","readme":"# BBC micro:bit MicroPython DHT12 I2C\n\nA micro:bit 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# Examples\n\nIn these examples, I am using pins 13 and 15 for [I2C](http://microbit-micropython.readthedocs.io/en/latest/i2c.html) clock and data, however, you can use any pin. Pins 13 and 15 are normally used for SPI.\nMy Kitronik edge connector breakout board does not have pin headers soldered for the [standard I2C pins](http://microbit-micropython.readthedocs.io/en/latest/pin.html) 19 and 20 (where you can find the accelerometer and compass), otherwise I'd be using them.\n\nBasic measurement\n\n```python\nfrom microbit import *\nimport dht12\n\ni2c.init(sda=pin15, scl=pin13)\nsensor = dht12.DHT12(i2c)\n\nsensor.measure()\nprint(sensor.temperature())\nprint(sensor.humidity())\n```\n\nPress Button A to measure, Button B to exit\n\n```python\nfrom microbit import *\nimport dht12\n\ni2c.init(sda=pin15, scl=pin13)\nsensor = dht12.DHT12(i2c)\n\nwhile True:\n\tif button_a.is_pressed():\n\t\ttry:\n\t\t\tsensor.measure()\n\t\t\tdisplay.scroll(str(sensor.temperature())+\"c\", 50)\n\t\texcept OSError:\n\t\t\tdisplay.scroll(\"Err\")\n\tif button_b.is_pressed():\n\t\tdisplay.scroll(\"End\")\n\t\tbreak\n```\n\nContinuous measurement\n\n```python\nfrom microbit import *\nimport dht12\n\ni2c.init(sda=pin15, scl=pin13)\nsensor = dht12.DHT12(i2c)\n\nwhile True:\n\ttry:\n\t\tsensor.measure()\n\t\tprint(sensor.temperature())\n\t\tprint(sensor.humidity())\n\t\tsleep(4000)\n\texcept OSError:\n\t\tprint(\"Error\")\n\t\tsleep(1000)\n```\n\n## Links\n\n* [BBC micro:bit](http://microbit.org/)\n* [MicroPython for the BBC micro:bit](https://github.com/bbcmicrobit/micropython)\n* [Kitronik Edge Connector Breakout Board](https://www.https://www.kitronik.co.uk/5601b-edge-connector-breakout-board-for-bbc-microbit-pre-built.html.co.uk/5601b-edge-connector-breakout-board-for-bbc-microbit-pre-built.html)\n* [micropython.org](http://micropython.org)\n* [micro:bit on the MicroPython forum](https://forum.micropython.org/viewforum.php?f=17)\n* [MicroPython DHT12](https://github.com/mcauser/micropython-dht12)\n\n## License\n\nLicensed under the [MIT License](http://opensource.org/licenses/MIT).\n","funding_links":[],"categories":["🐍 Python"],"sub_categories":["🐍 MicroPython Libraries"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcauser%2Fmicrobit-dht12","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmcauser%2Fmicrobit-dht12","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcauser%2Fmicrobit-dht12/lists"}