Merge branch 'master' of https://github.com/nodemcu/nodemcu-firmware
This commit is contained in:
commit
30a7274083
|
@ -1,15 +1,20 @@
|
||||||
#DS18B20 模块
|
#DS18B20 模块
|
||||||
##引用
|
##引用
|
||||||
|
```lua
|
||||||
ds18b20 = require("ds18b20")
|
ds18b20 = require("ds18b20")
|
||||||
|
```
|
||||||
|
#释放
|
||||||
|
```lua
|
||||||
|
ds18b20 = nil
|
||||||
|
package.loaded["ds18b20"]=nil
|
||||||
|
```
|
||||||
##常量
|
##常量
|
||||||
C, F, K
|
C, F, K
|
||||||
|
|
||||||
<a id="ds18b20_setup"></a>
|
<a id="ds18b20_setup"></a>
|
||||||
##setup()
|
##setup()
|
||||||
####描述
|
####描述
|
||||||
设置DS18B20所在的Pin。<br />
|
设置DS18B20所在的管脚(pin)。<br />
|
||||||
|
|
||||||
####语法
|
####语法
|
||||||
setup(pin)
|
setup(pin)
|
||||||
|
@ -24,6 +29,10 @@ nil
|
||||||
```lua
|
```lua
|
||||||
ds18b20 = require("ds18b20")
|
ds18b20 = require("ds18b20")
|
||||||
ds18b20.setup(9)
|
ds18b20.setup(9)
|
||||||
|
-- Don't forget release it after use
|
||||||
|
ds18b20 = nil
|
||||||
|
package.loaded["ds18b20"]=nil
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
####参见
|
####参见
|
||||||
|
@ -51,6 +60,10 @@ addrs = ds18b20.addrs()
|
||||||
if (addrs ~= nil) then
|
if (addrs ~= nil) then
|
||||||
print("Total DS18B20 sensors: "..table.getn(addrs))
|
print("Total DS18B20 sensors: "..table.getn(addrs))
|
||||||
end
|
end
|
||||||
|
-- Don't forget release it after use
|
||||||
|
ds18b20 = nil
|
||||||
|
package.loaded["ds18b20"]=nil
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
####参见
|
####参见
|
||||||
|
@ -94,6 +107,10 @@ print(t.readNumber())
|
||||||
print(t.readNumber(nil,t.F))
|
print(t.readNumber(nil,t.F))
|
||||||
-- Read as values
|
-- Read as values
|
||||||
t1, t2 = t.readNumber()
|
t1, t2 = t.readNumber()
|
||||||
|
-- Don't forget release it after use
|
||||||
|
t = nil
|
||||||
|
package.loaded["ds18b20"]=nil
|
||||||
|
|
||||||
```
|
```
|
||||||
####参见
|
####参见
|
||||||
**-** []()
|
**-** []()
|
||||||
|
@ -132,7 +149,9 @@ print(t.read(addrs[2],t.K))
|
||||||
print(t.read())
|
print(t.read())
|
||||||
-- Just read as centigrade
|
-- Just read as centigrade
|
||||||
print(t.read(nil,t.C))
|
print(t.read(nil,t.C))
|
||||||
|
-- Don't forget release it after use
|
||||||
|
t = nil
|
||||||
|
package.loaded["ds18b20"]=nil
|
||||||
```
|
```
|
||||||
####参见
|
####参见
|
||||||
**-** []()
|
**-** []()
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
#DS18B20 Module
|
#DS18B20 Module
|
||||||
##Require
|
##Require
|
||||||
|
```lua
|
||||||
ds18b20 = require("ds18b20")
|
ds18b20 = require("ds18b20")
|
||||||
|
```
|
||||||
|
## Release
|
||||||
|
```lua
|
||||||
|
ds18b20 = nil
|
||||||
|
package.loaded["ds18b20"]=nil
|
||||||
|
```
|
||||||
##Constant
|
##Constant
|
||||||
C, F, K
|
C, F, K
|
||||||
|
|
||||||
|
@ -24,6 +29,9 @@ nil
|
||||||
```lua
|
```lua
|
||||||
ds18b20 = require("ds18b20")
|
ds18b20 = require("ds18b20")
|
||||||
ds18b20.setup(9)
|
ds18b20.setup(9)
|
||||||
|
-- Don't forget release it after use
|
||||||
|
ds18b20 = nil
|
||||||
|
package.loaded["ds18b20"]=nil
|
||||||
```
|
```
|
||||||
|
|
||||||
####See also
|
####See also
|
||||||
|
@ -51,6 +59,9 @@ addrs = ds18b20.addrs()
|
||||||
if (addrs ~= nil) then
|
if (addrs ~= nil) then
|
||||||
print("Total DS18B20 sensors: "..table.getn(addrs))
|
print("Total DS18B20 sensors: "..table.getn(addrs))
|
||||||
end
|
end
|
||||||
|
-- Don't forget release it after use
|
||||||
|
ds18b20 = nil
|
||||||
|
package.loaded["ds18b20"]=nil
|
||||||
```
|
```
|
||||||
|
|
||||||
####See also
|
####See also
|
||||||
|
@ -94,6 +105,9 @@ print(t.readNumber())
|
||||||
print(t.readNumber(nil,t.F))
|
print(t.readNumber(nil,t.F))
|
||||||
-- Read as values
|
-- Read as values
|
||||||
t1, t2 = t.readNumber()
|
t1, t2 = t.readNumber()
|
||||||
|
-- Don't forget release it after use
|
||||||
|
t = nil
|
||||||
|
package.loaded["ds18b20"]=nil
|
||||||
```
|
```
|
||||||
####See also
|
####See also
|
||||||
**-** []()
|
**-** []()
|
||||||
|
@ -132,7 +146,9 @@ print(t.read(addrs[2],t.K))
|
||||||
print(t.read())
|
print(t.read())
|
||||||
-- Just read as centigrade
|
-- Just read as centigrade
|
||||||
print(t.read(nil,t.C))
|
print(t.read(nil,t.C))
|
||||||
|
-- Don't forget release it after use
|
||||||
|
t = nil
|
||||||
|
package.loaded["ds18b20"]=nil
|
||||||
```
|
```
|
||||||
####See also
|
####See also
|
||||||
**-** []()
|
**-** []()
|
||||||
|
|
Loading…
Reference in New Issue