{"id":13894201,"url":"https://github.com/RobTillaart/DHT12","last_synced_at":"2025-07-17T09:31:04.484Z","repository":{"id":45381846,"uuid":"255120181","full_name":"RobTillaart/DHT12","owner":"RobTillaart","description":"Arduino library for I2C DHT12 sensor","archived":false,"fork":false,"pushed_at":"2024-04-13T08:58:07.000Z","size":32,"stargazers_count":8,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-02T22:02:13.347Z","etag":null,"topics":["arduino-library","humidity","temperature"],"latest_commit_sha":null,"homepage":"","language":"C++","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/RobTillaart.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"RobTillaart","custom":"https://www.paypal.me/robtillaart"}},"created_at":"2020-04-12T16:07:34.000Z","updated_at":"2024-04-28T18:20:33.000Z","dependencies_parsed_at":"2024-04-13T09:52:20.492Z","dependency_job_id":"eef6a1fe-4e77-4b16-98d1-79708aa5aa69","html_url":"https://github.com/RobTillaart/DHT12","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/RobTillaart/DHT12","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobTillaart%2FDHT12","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobTillaart%2FDHT12/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobTillaart%2FDHT12/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobTillaart%2FDHT12/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RobTillaart","download_url":"https://codeload.github.com/RobTillaart/DHT12/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RobTillaart%2FDHT12/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265589080,"owners_count":23793464,"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":["arduino-library","humidity","temperature"],"created_at":"2024-08-06T18:01:26.358Z","updated_at":"2025-07-17T09:31:04.222Z","avatar_url":"https://github.com/RobTillaart.png","language":"C++","funding_links":["https://github.com/sponsors/RobTillaart","https://www.paypal.me/robtillaart"],"categories":["C++"],"sub_categories":[],"readme":"\n[![Arduino CI](https://github.com/RobTillaart/DHT12/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)\n[![Arduino-lint](https://github.com/RobTillaart/DHT12/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/DHT12/actions/workflows/arduino-lint.yml)\n[![JSON check](https://github.com/RobTillaart/DHT12/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/DHT12/actions/workflows/jsoncheck.yml)\n[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/DHT12.svg)](https://github.com/RobTillaart/DHT12/issues)\n\n[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/DHT12/blob/master/LICENSE)\n[![GitHub release](https://img.shields.io/github/release/RobTillaart/DHT12.svg?maxAge=3600)](https://github.com/RobTillaart/DHT12/releases)\n[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/DHT12.svg)](https://registry.platformio.org/libraries/robtillaart/DHT12)\n\n\n# DHT12\n\nArduino library for I2C DHT12 temperature and humidity sensor.\n\n\n## Description\n\nThe DHT12 is an I2C temperature and humidity sensor.\n\nThe constructor is called only with a TwoWire object (Wire, Wire1 etc) as the device \nhas a fixed address. The user should call **Wire.begin()** in setup before calling\nthe **begin()** function.\n\nThereafter one has to call the **read()** function to do the actual reading,\nand with **getTemperature()** and **getHumidity()** to get the read values.\nCalling these latter again will return the same values until a new **read()** is called.\n\n\n#### I2C\n\nThe DHT12 has a fixed I2C address of 0x5C. To use multiple DHT12's one need an\nI2C multiplexer like PCA9548 or TCA9548.\n\nThe DHT12 should work up to 400 KHz however this is not tested (yet).\n\n\n## Interface\n\n```cpp\n#include \"DHT12.h\"\n```\n\n\n#### Constructor\n\n- **DHT12(TwoWire \\*wire = \u0026Wire)** constructor, using a specific Wire (I2C bus).\nDefault is set to Wire.\n- **bool begin()** initializer for non ESP32. Returns true if connected.\n- **bool isConnected()** returns true if the address of the DHT12 can be seen on the I2C bus. (since 0.3.2)\n\n\n#### Core\n\n- **int8_t read()** read the sensor and store the values internally. It returns the status of the read which should be 0.\n- **float getHumidity()** returns last Humidity read, or -999 in case of error.\n- **float getTemperature()** returns last Temperature read, or -999 in case of error.\n- **uint32_t lastRead()** returns the timestamp of the last successful read in milliseconds since startup.\nIf zero there has been no **read()** called yet.\n\n\n#### Offset\n\n- **void setHumOffset(float offset = 0)** set an offset to calibrate (1st order) the sensor.\nDefault offset is 0.\n- **float getHumOffset()** return current humidity offset, default 0.\n- **void setTempOffset(float offset = 0)** set an offset to calibrate (1st order) the sensor.\nDefault offset is 0.\n- **float getTempOffset()** return current temperature offset, default 0.\n\n\n## Future\n\n#### Must\n\n- documentation \n  - related?\n\n#### Should\n\n- test at different I2C speeds \n  - 400 KHz should be possible.\n- add examples.\n\n\n#### Could\n\n- check for optimizations. although I2C overhead is much more.\n- add **void setIgnoreChecksum(bool = false)** ignore checksum flag speeds up communication a bit\n- add **bool getIgnoreChecksum()** get status. For completeness.\n- investigate if it is possible to extract temp and hum separately\n  - faster?\n- add **void suppressErrorReads(bool)** prevents the -999, returns previous value\n- add **bool getSuppressError()**\n\n\n#### Wont\n\n\n## Support\n\nIf you appreciate my libraries, you can support the development and maintenance.\nImprove the quality of the libraries by providing issues and Pull Requests, or\ndonate through PayPal or GitHub sponsors.\n\nThank you,\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRobTillaart%2FDHT12","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRobTillaart%2FDHT12","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRobTillaart%2FDHT12/lists"}