{"id":14965998,"url":"https://github.com/jonathanstowe/rpi-device-dht11","last_synced_at":"2026-01-20T06:33:10.865Z","repository":{"id":66980498,"uuid":"586201224","full_name":"jonathanstowe/RPi-Device-DHT11","owner":"jonathanstowe","description":"Interface to the DHT11 digital temperature/humidity sensor","archived":false,"fork":false,"pushed_at":"2023-01-07T19:24:13.000Z","size":300,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-15T09:35:21.483Z","etag":null,"topics":["dht11","humidity","raku","raspberry-pi","rpi","sensor","temperature"],"latest_commit_sha":null,"homepage":"","language":"Raku","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"artistic-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonathanstowe.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","contributing":null,"funding":null,"license":null,"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}},"created_at":"2023-01-07T09:51:35.000Z","updated_at":"2024-01-25T17:27:02.000Z","dependencies_parsed_at":"2023-05-16T10:00:36.122Z","dependency_job_id":null,"html_url":"https://github.com/jonathanstowe/RPi-Device-DHT11","commit_stats":{"total_commits":5,"total_committers":2,"mean_commits":2.5,"dds":"0.19999999999999996","last_synced_commit":"5b4e5a0cde62958c62ba10ea8e5bb03a11ee700c"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanstowe%2FRPi-Device-DHT11","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanstowe%2FRPi-Device-DHT11/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanstowe%2FRPi-Device-DHT11/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanstowe%2FRPi-Device-DHT11/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonathanstowe","download_url":"https://codeload.github.com/jonathanstowe/RPi-Device-DHT11/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248060440,"owners_count":21041159,"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":["dht11","humidity","raku","raspberry-pi","rpi","sensor","temperature"],"created_at":"2024-09-24T13:35:40.284Z","updated_at":"2026-01-20T06:33:10.839Z","avatar_url":"https://github.com/jonathanstowe.png","language":"Raku","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RPi::Device::DHT11\n\nInterface to the DHT11 digital temperature/humidity sensor\n\n[![CI](https://github.com/jonathanstowe/RPi-Device-DHT11/actions/workflows/main.yml/badge.svg)](https://github.com/jonathanstowe/RPi-Device-DHT11/actions/workflows/main.yml)\n\n## Synopsis\n\n```raku\nuse RPi::Device::DHT11;\n\nsub MAIN() {\n    my $dht = RPi::Device::DHT11.new(pin =\u003e 0, supply-interval =\u003e 1.5);\n\n    react {\n        whenever $dht -\u003e $reading {\n            say sprintf \"{ DateTime.now.Str }: Humidity is %.2f %%, \\t Temperature is %.2f *C\", $reading.humidity, $reading.temperature;\n        }\n    }\n}\n```\n\n## Description\n\nThe DHT11 is a common and inexpensive temperate and humidity sensor with a single pin digital interface. It has a reasonable degree of accuracy ( 1-2% on relative humidity and 0.2°C or so.)\n\nTo hook the DHT11 up you only need a pull-up resistor (the datasheets indicate 5KΩ but 10K seems to work fine.) It will not work reliably (or at all,) without the pull-up.\n\nA typical setup would be:\n\n[![Minimal Circuit](https://raw.githubusercontent.com/jonathanstowe/RPi-Device-DHT11/main/examples/hardware/dht11.png)](https://raw.githubusercontent.com/jonathanstowe/RPi-Device-DHT11/main/examples/hardware/dht11.png)\n\nYou may want to check the pinout of the actual device you have, there are, for example, some boards that mount the device on a little PCB with only the three used pins exposed, and I've seen pictures of some with the pins in the reverse direction (i.e. Vcc and Gnd swapped,) from that shown.\n\nPlease note that because this uses the wiringPi library under the hood the [wiringPi pin numbers](http://wiringpi.com/pins/) are used, so in the above the data line is connected to the sixth pin down from the top on the left (assuming the end with the USB is \"down\",) which is wiringPi pin 0 (or GPIO 17 in the Broadcom numbering.) You can find the actual numbering for your Raspberry Pi with:\n\n    gpio readall\n\nwhich gives you a convenient table.\n\nThe easiest way to use this module is to use the object as a `Supply` as in the example above (it supplies a `Supply` coercion,) this will emit a `Reading` object at a minimum of `supply-interval` seconds frequency (the default is 1.5 seconds which is about the minimum usable value.)  The `Reading` object has `temperature` (in degrees Celsius,) and `humidity` (in percentage relative humidity,) attribute.\n\nThe `read` method returns a `Reading` object if a valid reading is obtained in `read-retries` attempts, or a type object otherwise, this doesn't place a constraint on how frequently it is called but you are likely to get fewer valid readings if called more frequently than 1.5 seconds.\n\nYou could potentially use multiple instances of this on different pins (having more than one on the same pin is guaranteed not to work,) but you should bear in mind that the code has to spin in a tight loop while it is getting a reading so you might experience high processor load and/or unreliable readings if you have too many.\n\n## Installation\n\nYou will need [WiringPi](https://github.com/WiringPi/WiringPi) to compile the C helper, your OS may have packages for it but since the original author discontinued support it has been removed from some more recent distributions, it is quite simple to install from source from the unofficial mirror.\n\nIf you have a working Raku installation with _zef_ you should be able to install this with:\n\n    zef install RPi::Device::DHT11\n\nIf you have a copy of this source locally and you want to run the tests separately before installing then you will need to build the C helper library first:\n\n    zef build .\n    zef test .\n    ...\n\n## Support\n\nI have only tested this with a single DHT11 but there are a number of similar devices available which may or may not work, if you experience problems it would be useful if you can indicate the actual device you are trying to use, as well as a wiring diagram (or even a picture,) of how you have it hooked up.\n\nBear in mind that I may have dismantled the circuit I use to test this so it might take a while to reproduce any problems.\n\nPlease direct any questions or patches etc to [Github](https://github.com/jonathanstowe/RPi-Device-DHT11/issues) in the first instance.\n\n## Copyright\n\n© Jonathan Stowe 2023\n\nThis is free software, please see the [LICENCE](LICENCE) file in this distribution for details.\n\nThe [src/dht.c](src/dht.c) is modified from the [DHT.cpp](https://github.com/Freenove/Freenove_Ultimate_Starter_Kit_for_Raspberry_Pi/blob/master/Code/C_Code/21.1.1_DHT11/DHT.cpp) which is licensed [CC BY-NC-SA 3.0](https://github.com/Freenove/Freenove_Ultimate_Starter_Kit_for_Raspberry_Pi/blob/master/LICENSE.txt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathanstowe%2Frpi-device-dht11","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonathanstowe%2Frpi-device-dht11","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathanstowe%2Frpi-device-dht11/lists"}