{"id":13613036,"url":"https://github.com/mcauser/micropython-am2320","last_synced_at":"2025-03-25T08:31:13.430Z","repository":{"id":57441463,"uuid":"69221050","full_name":"mcauser/micropython-am2320","owner":"mcauser","description":"MicroPython driver for the Aosong AM2320 temperature and humidity sensor","archived":false,"fork":false,"pushed_at":"2024-02-16T15:50:05.000Z","size":1280,"stargazers_count":25,"open_issues_count":0,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-19T23:02:13.925Z","etag":null,"topics":["am2320","dht","humidity","micropython","temperature"],"latest_commit_sha":null,"homepage":"","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}},"created_at":"2016-09-26T06:46:18.000Z","updated_at":"2024-02-16T15:48:37.000Z","dependencies_parsed_at":"2022-09-05T23:51:52.351Z","dependency_job_id":null,"html_url":"https://github.com/mcauser/micropython-am2320","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcauser%2Fmicropython-am2320","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcauser%2Fmicropython-am2320/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcauser%2Fmicropython-am2320/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcauser%2Fmicropython-am2320/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mcauser","download_url":"https://codeload.github.com/mcauser/micropython-am2320/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245426212,"owners_count":20613304,"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":["am2320","dht","humidity","micropython","temperature"],"created_at":"2024-08-01T20:00:38.300Z","updated_at":"2025-03-25T08:31:12.966Z","avatar_url":"https://github.com/mcauser.png","language":"Python","readme":"# MicroPython AM2320 I2C\n\nA MicroPython library for interfacing with an [Aosong AM2320](http://www.aosong.com/en/products-41.html) 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-am2320\n$ mpremote mip install github:mcauser/micropython-am2320/examples\n```\n\nUsing mip directly on a WiFi capable board:\n\n```python\n\u003e\u003e\u003e import mip\n\u003e\u003e\u003e mip.install(\"github:mcauser/micropython-am2320\")\n\u003e\u003e\u003e mip.install(\"github:mcauser/micropython-am2320/examples\")\n```\n\nManual installation:\n\nCopy `src/am2320.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 am2320\n\ni2c = I2C(0)\nsensor = am2320.AM2320(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### _wake()\n\nThe sensor goes into sleep mode when idle to help minimise influencing the readings and requires writing a byte to wake it back up.\nThe write will fail, however the sensor interprets it as a wake up call.\n\n### _crc16(buf)\n\nA 16-bit cyclic redundancy check for verifying the received data is error free.\n\n\n## Parts\n\n* [AM2320](https://s.click.aliexpress.com/e/_DCcOdjL)\n* [AM2320](https://s.click.aliexpress.com/e/_DeLEjAD)\n* [TinyPICO](https://www.tinypico.com/)\n* [WeMos D1 Mini](https://www.aliexpress.com/item/32529101036.html)\n\n\n## Connections\n\nAM2320 | TinyPICO (ESP32)\n------ | ----------------\nVIN    | 3V3\nSDA    | 22\nGND    | GND\nSCL    | 21\n\nAM2320 | 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* [AM2320 datasheet](docs/AM2320.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","funding_links":[],"categories":["Libraries","精选驱动库"],"sub_categories":["Sensors","传感器"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcauser%2Fmicropython-am2320","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmcauser%2Fmicropython-am2320","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcauser%2Fmicropython-am2320/lists"}