From fb10825c1325886bf2e7829e6f4e0a663d9f7139 Mon Sep 17 00:00:00 2001 From: Martin Han Date: Fri, 30 Jan 2015 21:21:18 +0800 Subject: [PATCH] BH1750 User's Manual --- lua_modules/bh1750/bh1750_EN.md | 105 ++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 lua_modules/bh1750/bh1750_EN.md diff --git a/lua_modules/bh1750/bh1750_EN.md b/lua_modules/bh1750/bh1750_EN.md new file mode 100644 index 00000000..5e2a5ece --- /dev/null +++ b/lua_modules/bh1750/bh1750_EN.md @@ -0,0 +1,105 @@ +# bh1750 Module + +##Require +```lua +bh1750 = require("bh1750") +``` +## Release +```lua +bh1750 = nil +package.loaded["bh1750"]=nil +``` + +##init() +####Description +Setting the I2C pin of bh1750.
+ +####Syntax +init(sda, scl) + +####Parameters +sda: 1~12, IO index.
+scl: 1~12, IO index.
+ +####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 +**-** []() + + +##read() +####Description +Read Lux data from bh1750.
+ +####Syntax +read() + +####Parameters +nil.
+ +####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) +bh1750.read() + +-- release module +bh1750 = nil +package.loaded["bh1750"]=nil +``` + +####See also +**-** []() + + +##getlux() +####Description +Get lux from bh1750.
+ +####Syntax +getlux() + +####Parameters +nil.
+ +####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 +**-** []()