@abandonware/bh1750 中文文档教程
bh1750
由基于 i2c lib 的树莓派控制的光传感器 BH1750
Usage
Usage with Node.JS runtime
npm install
npm test
# light value is: 20 lx
Usage with IoT.js runtime
对于受限环境:(
iotjs example/index.js
# light value is: 20.833333333333336 lx
Code
var BH1750 = require('bh1750');
var light = new BH1750({
//options
});
light.readLight(function(err, value){
if (err) {
console.log("light error: " + err);
throw err;
} else {
console.log("light value is: ", value, "lx");
}
});
Options
{
address: 0x23,
device: '/dev/i2c-1',
command: 0x10,
length: 2
}
Possible commands
// No active state
0x00
// Wating for measurment command
0x01
// Reset data register value - not accepted in POWER_DOWN mode
0x07
// Start measurement at 1lx resolution. Measurement time is approx 120ms.
0x10
// Start measurement at 0.5lx resolution. Measurement time is approx 120ms.
0x11
// Start measurement at 4lx resolution. Measurement time is approx 16ms.
0x13
// Start measurement at 1lx resolution. Measurement time is approx 120ms.
// Device is automatically set to Power Down after measurement.
0x20
// Start measurement at 0.5lx resolution. Measurement time is approx 120ms.
// Device is automatically set to Power Down after measurement.
0x21
// Start measurement at 1lx resolution. Measurement time is approx 120ms.
// Device is automatically set to Power Down after measurement.
0x23
License
麻省理工学院许可证)
版权所有 (c) 2013 Christophe Hamerling
特此免费授予任何获得许可的人 此软件和相关文档文件的副本( “软件”),不受限制地处理软件,包括 但不限于使用、复制、修改、合并、发布、 分发、再许可和/或出售软件的副本,以及 允许向其提供软件的人这样做,但须遵守 下列条件:
上述版权声明和本许可声明应 包含在软件的所有副本或重要部分中。
本软件按“原样”提供,不提供任何形式的保证, 明示或暗示的,包括但不限于 适销性、特定用途的适用性和非侵权性。 在任何情况下,作者或版权持有人均不对任何 索赔、损害赔偿或其他责任,无论是在合同行为中, 侵权行为或其他由以下原因引起、由其引起或与之相关的行为 软件或软件的使用或其他交易。
Resources
- https://www.npmjs.com/package/bh1750
- https://www.rohm.com/documents/11308/12926/CNA09016_sg.pdf
- http://www.mouser.com/ds/2/348/bh1750fvi-e-186247.pdf
- https://github.com/rzr/generic-sensors-lite
- https://github.com/rzr/webthing-iotjs/wiki/Sensor
bh1750
light sensor BH1750 controlled by raspberry pi based on i2c lib
Usage
Usage with Node.JS runtime
npm install
npm test
# light value is: 20 lx
Usage with IoT.js runtime
For constrained environments:
iotjs example/index.js
# light value is: 20.833333333333336 lx
Code
var BH1750 = require('bh1750');
var light = new BH1750({
//options
});
light.readLight(function(err, value){
if (err) {
console.log("light error: " + err);
throw err;
} else {
console.log("light value is: ", value, "lx");
}
});
Options
{
address: 0x23,
device: '/dev/i2c-1',
command: 0x10,
length: 2
}
Possible commands
// No active state
0x00
// Wating for measurment command
0x01
// Reset data register value - not accepted in POWER_DOWN mode
0x07
// Start measurement at 1lx resolution. Measurement time is approx 120ms.
0x10
// Start measurement at 0.5lx resolution. Measurement time is approx 120ms.
0x11
// Start measurement at 4lx resolution. Measurement time is approx 16ms.
0x13
// Start measurement at 1lx resolution. Measurement time is approx 120ms.
// Device is automatically set to Power Down after measurement.
0x20
// Start measurement at 0.5lx resolution. Measurement time is approx 120ms.
// Device is automatically set to Power Down after measurement.
0x21
// Start measurement at 1lx resolution. Measurement time is approx 120ms.
// Device is automatically set to Power Down after measurement.
0x23
License
(The MIT License)
Copyright (c) 2013 Christophe Hamerling <christophe.hamerling@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Resources
- https://www.npmjs.com/package/bh1750
- https://www.rohm.com/documents/11308/12926/CNA09016_sg.pdf
- http://www.mouser.com/ds/2/348/bh1750fvi-e-186247.pdf
- https://github.com/rzr/generic-sensors-lite
- https://github.com/rzr/webthing-iotjs/wiki/Sensor