{"id":21028024,"url":"https://github.com/d2r2/go-bh1750","last_synced_at":"2026-05-20T03:37:01.894Z","repository":{"id":57507562,"uuid":"156374012","full_name":"d2r2/go-bh1750","owner":"d2r2","description":"Golang library to interact with BH1750 ambient light sensor from Raspberry PI.","archived":false,"fork":false,"pushed_at":"2018-12-22T06:17:56.000Z","size":615,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-02-13T09:20:03.936Z","etag":null,"topics":["ambient-light-sensor","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}},"created_at":"2018-11-06T11:34:52.000Z","updated_at":"2022-07-27T16:39:11.000Z","dependencies_parsed_at":"2022-09-19T05:30:44.322Z","dependency_job_id":null,"html_url":"https://github.com/d2r2/go-bh1750","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/d2r2/go-bh1750","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d2r2%2Fgo-bh1750","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d2r2%2Fgo-bh1750/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d2r2%2Fgo-bh1750/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d2r2%2Fgo-bh1750/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/d2r2","download_url":"https://codeload.github.com/d2r2/go-bh1750/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d2r2%2Fgo-bh1750/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33244800,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-20T03:30:51.439Z","status":"ssl_error","status_checked_at":"2026-05-20T03:30:49.443Z","response_time":356,"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":["ambient-light-sensor","golang","gpio","i2c","i2c-sensors","raspberry-pi"],"created_at":"2024-11-19T11:53:39.884Z","updated_at":"2026-05-20T03:37:01.867Z","avatar_url":"https://github.com/d2r2.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\nBH1750 ambient light sensor\n=====================\n\n[![Build Status](https://travis-ci.org/d2r2/go-bh1750.svg?branch=master)](https://travis-ci.org/d2r2/go-bh1750)\n[![Go Report Card](https://goreportcard.com/badge/github.com/d2r2/go-bh1750)](https://goreportcard.com/report/github.com/d2r2/go-bh1750)\n[![GoDoc](https://godoc.org/github.com/d2r2/go-bh1750?status.svg)](https://godoc.org/github.com/d2r2/go-bh1750)\n[![MIT License](http://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE)\n\nBH1750 ([general specification](https://raw.github.com/d2r2/go-bh1750/master/docs/bh1750fvi-e-186247.pdf)) is a power effective ambient light sensor with spectral response close to human eye. Sensor returns measured ambient light value in lux units. Easily integrated with Arduino and Raspberry PI via i2c communication interface:\n![image](https://raw.github.com/d2r2/go-bh1750/master/docs/bh1750.jpg)\n\nHere is a library written in [Go programming language](https://golang.org/) for Raspberry PI and counterparts, which gives you in the output ambient light value (making all necessary i2c-bus interacting and values computing).\n\nGolang usage\n------------\n\n\n```go\nfunc main() {\n\t// Create new connection to i2c-bus on 0 line with address 0x23.\n\t// Use i2cdetect utility to find device address over the i2c-bus\n\ti2c, err := i2c.NewI2C(0x23, 0)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer i2c.Close()\n\n\tsensor := bh1750.NewBH1750()\n\n\tresolution := bh1750.HighResolution\n\tamb, err := sensor.MeasureAmbientLight(i2c, resolution)\n\tif err != nil {\n\t\tlg.Fatal(err)\n\t}\n\tlog.Printf(\"Ambient light (%s) = %v lx\", resolution, amb)\n```\n\n\nGetting help\n------------\n\nGoDoc [documentation](http://godoc.org/github.com/d2r2/go-bh1750)\n\nInstallation\n------------\n\n```bash\n$ go get -u github.com/d2r2/go-bh1750\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\nContact\n-------\n\nPlease use [Github issue tracker](https://github.com/d2r2/go-bh1750/issues) for filing bugs or feature requests.\n\n\nLicense\n-------\n\nGo-bh1750 is licensed under MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd2r2%2Fgo-bh1750","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fd2r2%2Fgo-bh1750","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd2r2%2Fgo-bh1750/lists"}