Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
fb10825c
Commit
fb10825c
authored
Jan 30, 2015
by
Martin Han
Browse files
BH1750 User's Manual
parent
555d64af
Changes
1
Show whitespace changes
Inline
Side-by-side
lua_modules/bh1750/bh1750_EN.md
0 → 100644
View file @
fb10825c
# bh1750 Module
##Require
```
lua
bh1750
=
require
(
"bh1750"
)
```
## Release
```
lua
bh1750
=
nil
package.loaded
[
"bh1750"
]
=
nil
```
<a
id=
"bh1750_init"
></a>
##init()
####Description
Setting the I2C pin of bh1750.
<br
/>
####Syntax
init(sda, scl)
####Parameters
sda: 1~12, IO index.
<br
/>
scl: 1~12, IO index.
<br
/>
####Returns
nil
####Example
```
lua
SDA_PIN
=
6
-- sda pin, GPIO12
SCL_PIN
=
5
-- scl pin, GPIO14
bh1750
=
require
(
"bh1750"
)
bh1750
.
init
(
SDA_PIN
,
SCL_PIN
)
-- release module
bh1750
=
nil
package.loaded
[
"bh1750"
]
=
nil
```
####See also
**-**
[](
)
<a
id=
"bh1750_read"
></a>
##read()
####Description
Read Lux data from bh1750.
<br
/>
####Syntax
read()
####Parameters
nil.
<br
/>
####Returns
nil.
<br
/>
####Example
```
lua
SDA_PIN
=
6
-- sda pin, GPIO12
SCL_PIN
=
5
-- scl pin, GPIO14
bh1750
=
require
(
"bh1750"
)
bh1750
.
init
(
SDA_PIN
,
SCL_PIN
)
bh1750
.
read
()
-- release module
bh1750
=
nil
package.loaded
[
"bh1750"
]
=
nil
```
####See also
**-**
[](
)
<a
id=
"bh1750_getlux"
></a>
##getlux()
####Description
Get lux from bh1750.
<br
/>
####Syntax
getlux()
####Parameters
nil.
<br
/>
####Returns
l: Integer, getlux from bh1750.
####Example
```
lua
SDA_PIN
=
6
-- sda pin, GPIO12
SCL_PIN
=
5
-- scl pin, GPIO14
bh1750
=
require
(
"bh1750"
)
bh1750
.
init
(
SDA_PIN
,
SCL_PIN
)
bh1750
.
read
()
l
=
bh1750
.
getlux
()
print
(
"lux: "
..
(
l
/
100
)
..
"."
..
(
l
%
100
)
..
" lx"
)
-- release module
bh1750
=
nil
package.loaded
[
"bh1750"
]
=
nil
```
####See also
**-**
[](
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment