{"id":15172917,"url":"https://github.com/github0013/rpi-dht","last_synced_at":"2026-01-25T21:44:14.171Z","repository":{"id":56892717,"uuid":"302320039","full_name":"github0013/rpi-dht","owner":"github0013","description":"If you are a ruby developer and want to use a DHT 11/22 sensor on a Raspberry Pi, this is it.","archived":false,"fork":false,"pushed_at":"2020-10-09T01:15:52.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-02T12:04:54.736Z","etag":null,"topics":["dht","dht11","dht22","gpio","raspberrypi","ruby"],"latest_commit_sha":null,"homepage":"https://github.com/github0013/rpi-dht","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/github0013.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-08T11:35:14.000Z","updated_at":"2020-10-09T01:15:54.000Z","dependencies_parsed_at":"2022-08-20T16:10:21.842Z","dependency_job_id":null,"html_url":"https://github.com/github0013/rpi-dht","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/github0013/rpi-dht","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github0013%2Frpi-dht","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github0013%2Frpi-dht/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github0013%2Frpi-dht/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github0013%2Frpi-dht/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/github0013","download_url":"https://codeload.github.com/github0013/rpi-dht/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github0013%2Frpi-dht/sbom","scorecard":{"id":428250,"data":{"date":"2025-08-11","repo":{"name":"github.com/github0013/rpi-dht","commit":"62440b3fa2cabb6138d6335c04c85b03b89c77f3"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.5,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/19 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":9,"reason":"1 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-jppv-gw3r-w3q8"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-19T02:43:32.441Z","repository_id":56892717,"created_at":"2025-08-19T02:43:32.441Z","updated_at":"2025-08-19T02:43:32.441Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28759426,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-25T20:56:06.009Z","status":"ssl_error","status_checked_at":"2026-01-25T20:54:48.203Z","response_time":113,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","dht11","dht22","gpio","raspberrypi","ruby"],"created_at":"2024-09-27T10:23:34.678Z","updated_at":"2026-01-25T21:44:14.156Z","avatar_url":"https://github.com/github0013.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rpi::Dht\n\nWritten purly in Ruby (except external gems)!\n\n## datasheet references\n\n- [dht11][1]\n- [dht22][2]\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```rb\ngem \"rpi-dht\"\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install rpi-dht\n\n## Usage\n\n```rb\nrequire \"rpi/dht\"\n\npin = 4 # bcm number https://i.gyazo.com/8de74c9e6a7139e30c2f540715a24dc9.png\n\n####################\n# GPIO numbering\n####################\n# RPi::Dht.set_numbering(:bcm)        [default]\n# or RPi::Dht.set_numbering(:board)\n\n# Because it can't receive valid data from sensor reliably, there are methods try to read continusly until it gets valid data\n# [read_11 and read_22] (without !) are recommended\n\n####################\n# for DHT11 sensor\n####################\nRPi::Dht.read_11!(pin) # raises exception, if you want to manage by yourself\n# =\u003e returns e.g. {humidity: 12, temperature: 34, temperature_f: 93.2}\n# or exception\n\nRPi::Dht.read_11(pin, tries: 50) # tries 50 times and doesn't raise\n# or RPi::Dht.read_11(pin) defaults to 50 tries\n# =\u003e returns e.g. {humidity: 12, temperature: 34, temperature_f: 93.2}\n# or nil if it doesn't get valid data\n\n####################\n# for DHT22 sensor\n####################\nRPi::Dht.read_22!(pin) # raises exception, if you want to manage by yourself\n# =\u003e returns e.g. {humidity: 12.3, temperature: 34.5, temperature_f: 94.1}\n# or exception\n\nRPi::Dht.read_22(pin, tries: 50) # tries 50 times and doesn't raise\n# or RPi::Dht.read_22(pin) defaults to 50 tries\n# =\u003e returns e.g. {humidity: 12.3, temperature: 34.5, temperature_f: 94.1}\n# or nil if it doesn't get valid data\n```\n\n## OR ...\n\n    $ uname -a\n    Linux rpi16gb 5.4.51+ #1333 Mon Aug 10 16:38:02 BST 2020 armv6l GNU/Linux\n\n    $ lsb_release -a\n    No LSB modules are available.\n    Distributor ID:\tRaspbian\n    Description:\tRaspbian GNU/Linux 10 (buster)\n    Release:\t10\n    Codename:\tbuster\n\n    $ cat /proc/cpuinfo\n    processor\t: 0\n    model name\t: ARMv6-compatible processor rev 7 (v6l)\n    BogoMIPS\t: 697.95\n    Features\t: half thumb fastmult vfp edsp java tls\n    CPU implementer\t: 0x41\n    CPU architecture: 7\n    CPU variant\t: 0x0\n    CPU part\t: 0xb76\n    CPU revision\t: 7\n\n    Hardware\t: BCM2835\n    Revision\t: 0010\n    Serial\t\t: 000000005f8c6a39\n    Model\t\t: Raspberry Pi Model B Plus Rev 1.2\n\nI am using a Raspberry Pi Model B Plus Rev 1.2 (fairly old) and it takes significant amount of time to read.\n\n### Sample source code\n\n```rb\n# read.rb\nrequire \"benchmark\"\nrequire \"rpi/dht\"\nPIN = 4\n\nBenchmark.bm 10 do |r|\n  r.report \"reading 10 times\" do\n    10.times { RPi::Dht.read_22(PIN) }\n  end\nend\n```\n\n    $ time ruby read.rb\n                    user     system      total        real\n    reading 10 times  2.025668   0.022232   2.047900 ( 55.610802)\n    ruby read.rb  4.62s user 0.52s system 8% cpu 58.773 total\n\n### Solution\n\nI just found there is **a device tree overlay for DHT11/22**. If you set this up, you can just read system files to read humidity and temperature.\n\n    $ cat /sys/bus/iio/devices/iio\\:device0/in_humidityrelative_input\n    43300\n\n    $ cat /sys/bus/iio/devices/iio\\:device0/in_temp_input\n    27100\n\n### Setup\n\n1. take the SD card from your Raspberry Pi\n1. edit /boot/config on your computer\n1. add `dtoverlay=dht11` at the bottom\n1. set the SD card back to your Raspberry Pi\n1. run `lsmod | grep dht`, and you should see something like this\n   - `dht11 16384 0`\n1. run `cat /sys/bus/iio/devices/iio\\:device0/in_humidityrelative_input` for humidity, then devide the number by 1000\n1. run `cat /sys/bus/iio/devices/iio\\:device0/in_temp_input` for temperature, then devide the number by 1000\n\nIt sometimes gives `Connection timed out` error, so maybe you can write something like this.\n\n```rb\nrequire \"pathname\"\n\ndef read_humidity\n  Pathname(\"/sys/bus/iio/devices/iio\\:device0/in_humidityrelative_input\").read.to_f / 1000\nrescue =\u003e ex\n  sleep 0.5\n  retry\nend\n\ndef read_temperature\n  Pathname(\"/sys/bus/iio/devices/iio\\:device0/in_temp_input\").read.to_f / 1000\nrescue =\u003e ex\n  sleep 0.5\n  retry\nend\n```\n\nbang!\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/github0013/rpi-dht.\n\n[1]: https://akizukidenshi.com/download/ds/aosong/DHT11.pdf\n[2]: https://akizukidenshi.com/download/ds/aosong/AM2302.pdf\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgithub0013%2Frpi-dht","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgithub0013%2Frpi-dht","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgithub0013%2Frpi-dht/lists"}