{"id":15172891,"url":"https://github.com/y9o/dht","last_synced_at":"2026-02-23T22:32:23.005Z","repository":{"id":238420309,"uuid":"796513144","full_name":"y9o/dht","owner":"y9o","description":"golang dht22 sensor reader","archived":false,"fork":false,"pushed_at":"2024-05-13T11:12:36.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-29T09:42:34.296Z","etag":null,"topics":["dht22","raspberry-pi"],"latest_commit_sha":null,"homepage":"","language":"Go","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/y9o.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2024-05-06T05:07:03.000Z","updated_at":"2024-05-13T11:10:14.000Z","dependencies_parsed_at":"2024-05-13T12:30:28.735Z","dependency_job_id":"cb65b2e2-3697-4659-bc54-c1da765e9759","html_url":"https://github.com/y9o/dht","commit_stats":null,"previous_names":["y9o/dht"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/y9o%2Fdht","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/y9o%2Fdht/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/y9o%2Fdht/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/y9o%2Fdht/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/y9o","download_url":"https://codeload.github.com/y9o/dht/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239686377,"owners_count":19680513,"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":["dht22","raspberry-pi"],"created_at":"2024-09-27T10:22:35.130Z","updated_at":"2025-10-07T02:06:57.366Z","avatar_url":"https://github.com/y9o.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dht\r\ngolang dht11/dht12/dht22 sensor reader\r\n\r\n```go\r\nd, err := dht.New(\"/dev/gpiochip0\", 4)\r\nif err != nil {\r\n\tlog.Fatal(err)\r\n}\r\ndefer d.Close()\r\n\r\nvar buf dht.DHT22Data\r\n//var buf dht.DHT11Data\r\n//var buf dht.DHT12Data\r\n\r\nfmt.Print(\"read...\\r\")\r\nif retry, err := d.Read(\u0026buf, 20); err != nil {\r\n\tfmt.Print(err)\r\n} else {\r\n\tfmt.Printf(\"🌡️%2.1f℃ (%d) 🌢%2.1f%% (%d) retry:%d\\n\", buf.Temp(), buf.Temperature, buf.Hum(), buf.Humidity, retry)\r\n}\r\n```\r\n\r\n\r\n```\r\n🌡️25.1℃ (251) 🌢59.2% (592) retry:2\r\n```\r\n\r\n\r\n\u003cdetails\u003e\r\n\u003csummary\u003eexample\u003c/summary\u003e\r\n\r\nbuild for pi zero on windows\r\n```bat\r\nset GOOS=linux\r\nset GOARCH=arm\r\nset GOARM=6\r\nset CGO_ENABLED=0\r\n\r\ngo build -ldflags=\"-s -w\"  -trimpath \r\nmove dht22 oridht22\r\nupx --lzma -o dht22 oridht22\r\ndel oridht22\r\n```\r\n\r\n\r\n```bash\r\n$ uname -r\r\n6.6.28+rpt-rpi-v6\r\n\r\n$ ./dht22\r\n./dht22 -chip gpiochip0\r\n\r\n$ ./dht22 -chip gpiochip0\r\n./dht22 -chip gpiochip0\r\n                -line 0         (ID_SDA)\r\n                -line 1         (ID_SCL)\r\n                -line 2         (GPIO2)\r\n                -line 3         (GPIO3)\r\n                -line 4         (GPIO4)\r\n                -line 5         (GPIO5)\r\n                -line 6         (GPIO6)\r\n                -line 7         (GPIO7)\r\n                -line 8         (GPIO8)\r\n                -line 9         (GPIO9)\r\n                -line 10                (GPIO10)\r\n                -line 11                (GPIO11)\r\n                -line 12                (GPIO12)\r\n                -line 13                (GPIO13)\r\n                -line 14                (GPIO14)\r\n                -line 15                (GPIO15)\r\n                -line 16                (GPIO16)\r\n                -line 17                (GPIO17)\r\n                -line 18                (GPIO18)\r\n                -line 19                (GPIO19)\r\n                -line 20                (GPIO20)\r\n                -line 21                (GPIO21)\r\n                -line 22                (GPIO22)\r\n                -line 23                (GPIO23)\r\n                -line 24                (GPIO24)\r\n                -line 25                (GPIO25)\r\n                -line 26                (GPIO26)\r\n                -line 27                (GPIO27)\r\n                -line 28                (SDA0)\r\n                -line 29                (SCL0)\r\n                -line 30                (CTS0)\r\n                -line 31                (RTS0)\r\n                -line 32                (TXD0)\r\n                -line 33                (RXD0)\r\n                -line 34                (SD1_CLK)\r\n                -line 35                (SD1_CMD)\r\n                -line 36                (SD1_DATA0)\r\n                -line 37                (SD1_DATA1)\r\n                -line 38                (SD1_DATA2)\r\n                -line 39                (SD1_DATA3)\r\n                -line 40                (CAM_GPIO1)\r\n                -line 41                (WL_ON)\r\n                -line 42                (NC)\r\n                -line 43                (WIFI_CLK)\r\n                -line 44                (CAM_GPIO0)\r\n                -line 45                (BT_ON)\r\n                -line 46                (HDMI_HPD_N)\r\n                -line 47                (STATUS_LED_N)\r\n                -line 48                (SD_CLK_R)\r\n                -line 49                (SD_CMD_R)\r\n                -line 50                (SD_DATA0_R)\r\n                -line 51                (SD_DATA1_R)\r\n                -line 52                (SD_DATA2_R)\r\n                -line 53                (SD_DATA3_R)\r\n\r\n$ ./dht22 -chip gpiochip0  -line 4\r\n14:30:51 🌡️25.1℃ (251) 🌢59.2% (592) retry:2\r\n14:31:01 🌡️25.2℃ (252) 🌢59.3% (593) retry:0\r\n14:31:12 🌡️25.2℃ (252) 🌢59.2% (592) retry:1\r\n14:31:22 🌡️25.2℃ (252) 🌢59.2% (592) retry:0\r\n14:31:33 🌡️25.2℃ (252) 🌢59.6% (596) retry:1\r\n14:31:45 🌡️25.2℃ (252) 🌢60.6% (606) retry:2\r\n14:31:57 🌡️25.2℃ (252) 🌢59.3% (593) retry:2\r\n14:32:09 🌡️25.2℃ (252) 🌢59.2% (592) retry:2\r\n14:32:20 🌡️25.2℃ (252) 🌢59.2% (592) retry:1\r\n14:32:31 🌡️25.2℃ (252) 🌢59.2% (592) retry:1\r\n```\r\n\u003c/details\u003e\r\n\r\n## cgo with libgpiod v2 support\r\n\r\nThis module can be built with `CGO_ENABLED=0` or `CGO_ENABLED=1`.\r\n\r\nHowever, using CGO does not dramatically improve the reading success rate.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fy9o%2Fdht","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fy9o%2Fdht","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fy9o%2Fdht/lists"}