{"id":13481071,"url":"https://github.com/alvarowolfx/bh1750-androidthings","last_synced_at":"2026-06-09T04:33:05.141Z","repository":{"id":70564344,"uuid":"100563453","full_name":"alvarowolfx/bh1750-androidthings","owner":"alvarowolfx","description":"Android Things driver for BH1750 ambient light sensor","archived":false,"fork":false,"pushed_at":"2018-09-03T01:53:36.000Z","size":206,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-10T15:57:22.994Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alvarowolfx.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2017-08-17T05:03:36.000Z","updated_at":"2020-08-24T04:02:09.000Z","dependencies_parsed_at":"2023-03-05T12:45:35.689Z","dependency_job_id":null,"html_url":"https://github.com/alvarowolfx/bh1750-androidthings","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/alvarowolfx%2Fbh1750-androidthings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alvarowolfx%2Fbh1750-androidthings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alvarowolfx%2Fbh1750-androidthings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alvarowolfx%2Fbh1750-androidthings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alvarowolfx","download_url":"https://codeload.github.com/alvarowolfx/bh1750-androidthings/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241040739,"owners_count":19898924,"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":[],"created_at":"2024-07-31T17:00:48.373Z","updated_at":"2026-06-09T04:33:00.116Z","avatar_url":"https://github.com/alvarowolfx.png","language":"Java","funding_links":[],"categories":["Useful links"],"sub_categories":["Drivers"],"readme":"BH1750 driver for Android Things\n================================\n\nThis driver supports ROHM [BH1750][product_bh1750] ambient light sensor.\n\nNOTE: these drivers are not production-ready. They are offered as sample\nimplementations of Android Things user space drivers for common peripherals\nas part of the Developer Preview release. There is no guarantee\nof correctness, completeness or robustness.\n\nHow to use the driver\n---------------------\n\n### Gradle dependency\n\nTo use the `bh1750` driver, simply add the line below to your project's `build.gradle`,\nwhere `\u003cversion\u003e` matches the last version of the driver available on [jcenter][jcenter].\n\n```\ndependencies {\n    compile 'com.alvarowolfx.androidthings:driver-bh1750:\u003cversion\u003e'\n}\n```\n\n### Sample usage\n\n```java\nimport com.alvarowolfx.androidthings.driver.bh1750.Bh1750;\n\n// Access the ambient light sensor:\n\nBh1750 mBh1750;\n\ntry {\n    mBh1750 = new Bh1750(i2cBusName);\n} catch (IOException e) {\n    // couldn't configure the device...\n}\n\n// Read the current light level:\n\ntry {\n    float lightLevel = mBh1750.readLightLevel();\n} catch (IOException e) {\n    // error reading light level\n}\n\n// Close the ambient light sensor when finished:\n\ntry {\n    mBh1750.close();\n} catch (IOException e) {\n    // error closing sensor\n}\n```\n\nIf you need to read sensor values continuously, you can register the BH1750 with the system and\nlisten for sensor values using the [Sensor APIs][sensors]:\n```java\nSensorManager mSensorManager = getSystemService(Context.SENSOR_SERVICE);\nSensorEventListener mListener = ...;\nBh1750SensorDriver mSensorDriver;\n\nmSensorManager.registerDynamicSensorCallback(new SensorManager.DynamicSensorCallback() {\n    @Override\n    public void onDynamicSensorConnected(Sensor sensor) {\n        if (sensor.getType() == Sensor.TYPE_LIGHT) {\n            mSensorManager.registerListener(mListener, sensor,\n                    SensorManager.SENSOR_DELAY_NORMAL);\n        }\n    }\n});\n\ntry {\n    mSensorDriver = new Bh1750SensorDriver(i2cBusName);\n    mSensorDriver.registerLightSensor();\n} catch (IOException e) {\n    // Error configuring sensor\n}\n\n// Unregister and close the driver when finished:\n\nmSensorManager.unregisterListener(mListener);\nmSensorDriver.unregisterLightSensor();\ntry {\n    mSensorDriver.close();\n} catch (IOException e) {\n    // error closing sensor\n}\n```\nSchematic\n-------\n![schematic](https://raw.githubusercontent.com/alvarowolfx/bh1750-androidthings/master/assets/schematic.png)\n\nLicense\n-------\n\nLicensed to the Apache Software Foundation (ASF) under one or more contributor\nlicense agreements.  See the NOTICE file distributed with this work for\nadditional information regarding copyright ownership.  The ASF licenses this\nfile to you under the Apache License, Version 2.0 (the \"License\"); you may not\nuse this file except in compliance with the License.  You may obtain a copy of\nthe License at\n\n  http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\nWARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the\nLicense for the specific language governing permissions and limitations under\nthe License.\n\n[product_bh1750]: http://cpre.kmutnb.ac.th/esl/learning/bh1750-light-sensor/bh1750fvi-e_datasheet.pdf\n[jcenter]: https://bintray.com/google/androidthings/contrib-driver-bh1750/_latestVersion\n[sensors]: https://developer.android.com/guide/topics/sensors/sensors_overview.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falvarowolfx%2Fbh1750-androidthings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falvarowolfx%2Fbh1750-androidthings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falvarowolfx%2Fbh1750-androidthings/lists"}