bh1750 - bh1750 Digital light intensity sensor#
Adaptation status unknown
Note
This page document is automatically generated by this file. If there is any error, please submit issue or help modify pr, thank you!
Example
--Note: due to the use of sys.wait() all apis need to be used in the coroutine
-- Usage Examples
local bh1750 = require "bh1750"
i2cid = 0
i2c_speed = i2c.FAST
sys.taskInit(function()
i2c.setup(i2cid,i2c_speed)
bh1750.init(i2cid)--initialization, passing in i2c_id
while 1 do
local bh1750_data = bh1750.read_light()
log.info("bh1750_read_light", bh1750_data)
sys.wait(1000)
end
end)
bh1750.init(i2c_id)#
bh1750 Initialization
Parameters
Incoming Value Type |
Explanation |
---|---|
number |
The i2c bus id |
Return Value
return value type |
explanation |
---|---|
bool |
Successful return true |
Examples
bh1750.init(0)
bh1750.read_light()#
Getting bh1750 Data
Parameters
None
Return Value
return value type |
explanation |
---|---|
number |
Light intensity data, if read failure will return nil |
Examples
local bh1750_data = bh1750.read_light()
log.info("bh1750_read_light", bh1750_data)