{"id":15290593,"url":"https://github.com/d2r2/go-aosong","last_synced_at":"2025-04-13T10:11:58.980Z","repository":{"id":75776863,"uuid":"129074228","full_name":"d2r2/go-aosong","owner":"d2r2","description":"Golang library to interact with humidity and temperature Aosong Electronics DHT12/AM2320 sensors working via i2c-bus","archived":false,"fork":false,"pushed_at":"2019-03-13T12:56:45.000Z","size":2134,"stargazers_count":5,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-22T05:31:55.212Z","etag":null,"topics":["embedded-linux","golang","gpio","i2c","i2c-sensors","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/d2r2.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":"2018-04-11T10:08:22.000Z","updated_at":"2022-12-08T14:46:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"38ce1fe3-36f4-421e-ae85-ab843b81db7d","html_url":"https://github.com/d2r2/go-aosong","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d2r2%2Fgo-aosong","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d2r2%2Fgo-aosong/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d2r2%2Fgo-aosong/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d2r2%2Fgo-aosong/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/d2r2","download_url":"https://codeload.github.com/d2r2/go-aosong/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248695481,"owners_count":21146956,"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":["embedded-linux","golang","gpio","i2c","i2c-sensors","raspberry-pi"],"created_at":"2024-09-30T16:08:43.638Z","updated_at":"2025-04-13T10:11:58.959Z","avatar_url":"https://github.com/d2r2.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"Aosong Electronics DHT12, AM2320 humidity and temperature sensors\n=================================================================\n\n[![Build Status](https://travis-ci.org/d2r2/go-aosong.svg?branch=master)](https://travis-ci.org/d2r2/go-aosong)\n[![Go Report Card](https://goreportcard.com/badge/github.com/d2r2/go-aosong)](https://goreportcard.com/report/github.com/d2r2/go-aosong)\n[![GoDoc](https://godoc.org/github.com/d2r2/go-aosong?status.svg)](https://godoc.org/github.com/d2r2/go-aosong)\n[![MIT License](http://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE)\n\nDHT12 ([pdf reference](https://raw.github.com/d2r2/go-aosong/master/docs/DHT12.pdf)) and AM2320 ([pdf reference](https://raw.github.com/d2r2/go-aosong/master/docs/AM2320.pdf)) are relatively cheap and popular among Arduino and Raspberry PI developers.\nBoth sensors may operate via i2c-bus interface:\n![image](https://raw.github.com/d2r2/go-aosong/master/docs/am2320_dht12.jpg)\n\nHere is a library written in [Go programming language](https://golang.org/) for Raspberry PI and clones, which gives you in the output relative humidity and temperature values (making all necessary i2c-bus interacting and values computing).\n\nPay attention that this library only employ i2c-bus interaction approach. Other option to work with the sensors - specific \"single bus communication\" protocol is not implemented here.\n \nGolang usage\n------------\n\n```go\nfunc main() {\n\t// Create new connection to i2c-bus on 1 line with address 0x5C.\n\t// Use i2cdetect utility to find device address over the i2c-bus\n\ti2c, err := i2c.NewI2C(0x5C, 1)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer i2c.Close()\n\n\tsensor := aosong.NewSensor(aosong.DHT12)\n\n\tlog.Printf(\"Sensor type = %v\\n\", sensor.GetSensorType())\n\trh, t, err := sensor.ReadRelativeHumidityAndTemperature(i2c)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tlog.Printf(\"Relative humidity = %v%%\\n\", rh)\n\tlog.Printf(\"Temperature in celsius = %v*C\\n\", t)\n}\n```\n\n\nGetting help\n------------\n\nGoDoc [documentation](http://godoc.org/github.com/d2r2/go-aosong)\n\nInstallation\n------------\n\n```bash\n$ go get -u github.com/d2r2/go-aosong\n```\n\nTroubleshooting\n--------------\n\n- *How to obtain fresh Golang installation to RPi device (either any RPi clone):*\nIf your RaspberryPI golang installation taken by default from repository is outdated, you may consider\nto install actual golang manually from official Golang [site](https://golang.org/dl/). Download\ntar.gz file containing armv6l in the name. Follow installation instructions.\n\n- *How to enable I2C bus on RPi device:*\nIf you employ RaspberryPI, use raspi-config utility to activate i2c-bus on the OS level.\nGo to \"Interfacing Options\" menu, to active I2C bus.\nProbably you will need to reboot to load i2c kernel module.\nFinally you should have device like /dev/i2c-1 present in the system.\n\n- *How to find I2C bus allocation and device address:*\nUse i2cdetect utility in format \"i2cdetect -y X\", where X may vary from 0 to 5 or more,\nto discover address occupied by peripheral device. To install utility you should run\n`apt install i2c-tools` on debian-kind system. `i2cdetect -y 1` sample output:\n\t```\n\t     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f\n\t00:          -- -- -- -- -- -- -- -- -- -- -- -- --\n\t10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n\t20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n\t30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n\t40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n\t50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n\t60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n\t70: -- -- -- -- -- -- 76 --    \n\t```\n\nContribute authors\n------------------\n\n* [Efimov Ioan-Alexandru](https://github.com/efimovalex): report an [issue](https://github.com/d2r2/go-aosong/issues/2) and suggested a solution.\n\n\nContact\n-------\n\nPlease use [Github issue tracker](https://github.com/d2r2/go-aosong/issues) for filing bugs or feature requests.\n\n\nLicense\n-------\n\nGo-aosong is licensed under MIT License.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd2r2%2Fgo-aosong","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fd2r2%2Fgo-aosong","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd2r2%2Fgo-aosong/lists"}