* Update README.md and DS18B20 documents.

This commit is contained in:
HuangRui 2014-12-09 14:41:14 +08:00
parent 30a7274083
commit 2222995af4
3 changed files with 35 additions and 9 deletions

View File

@ -3,7 +3,7 @@
version 0.9.2 build 2014-12-09 version 0.9.2 build 2014-12-09
# Change log # Change log
2014-12-09<br /> 2014-12-09<br />
increase alarmer num in tmr module to 7. increased the number of alarm in tmr module, now it has 7 alarm. <br />
2014-12-08<br /> 2014-12-08<br />
add uart.setup(), uart.write() api.<br /> add uart.setup(), uart.write() api.<br />
@ -164,6 +164,32 @@ braudrate:9600
print("Welcome to NodeMcu world.") print("Welcome to NodeMcu world.")
end) end)
``` ```
####Use DS18B20 module extends your NODEMCU
```lua
-- read temperature with DS18B20
t=require("ds18b20")
t.setup(9)
addrs=t.addrs()
-- Total DS18B20 numbers, assume it is 2
print(table.getn(addrs))
-- The first DS18B20
print(t.read(addrs[1],t.C))
print(t.read(addrs[1],t.F))
print(t.read(addrs[1],t.K))
-- The second DS18B20
print(t.read(addrs[2],t.C))
print(t.read(addrs[2],t.F))
print(t.read(addrs[2],t.K))
-- Just read
print(t.read())
-- Just read as centigrade
print(t.read(nil,t.C))
-- Don't forget to release it after use
t = nil
package.loaded["ds18b20"]=nil
```
#Check this out #Check this out
Tencent QQ group: 309957875<br/> Tencent QQ group: 309957875<br/>
[nodemcu wiki](https://github.com/nodemcu/nodemcu-firmware/wiki)<br/> [nodemcu wiki](https://github.com/nodemcu/nodemcu-firmware/wiki)<br/>

View File

@ -29,7 +29,7 @@ nil
```lua ```lua
ds18b20 = require("ds18b20") ds18b20 = require("ds18b20")
ds18b20.setup(9) ds18b20.setup(9)
-- Don't forget release it after use -- Don't forget to release it after use
ds18b20 = nil ds18b20 = nil
package.loaded["ds18b20"]=nil package.loaded["ds18b20"]=nil
@ -60,7 +60,7 @@ 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 -- Don't forget to release it after use
ds18b20 = nil ds18b20 = nil
package.loaded["ds18b20"]=nil package.loaded["ds18b20"]=nil
@ -107,7 +107,7 @@ 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 -- Don't forget to release it after use
t = nil t = nil
package.loaded["ds18b20"]=nil package.loaded["ds18b20"]=nil
@ -149,7 +149,7 @@ 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 -- Don't forget to release it after use
t = nil t = nil
package.loaded["ds18b20"]=nil package.loaded["ds18b20"]=nil
``` ```

View File

@ -29,7 +29,7 @@ nil
```lua ```lua
ds18b20 = require("ds18b20") ds18b20 = require("ds18b20")
ds18b20.setup(9) ds18b20.setup(9)
-- Don't forget release it after use -- Don't forget to release it after use
ds18b20 = nil ds18b20 = nil
package.loaded["ds18b20"]=nil package.loaded["ds18b20"]=nil
``` ```
@ -59,7 +59,7 @@ 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 -- Don't forget to release it after use
ds18b20 = nil ds18b20 = nil
package.loaded["ds18b20"]=nil package.loaded["ds18b20"]=nil
``` ```
@ -105,7 +105,7 @@ 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 -- Don't forget to release it after use
t = nil t = nil
package.loaded["ds18b20"]=nil package.loaded["ds18b20"]=nil
``` ```
@ -146,7 +146,7 @@ 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 -- Don't forget to release it after use
t = nil t = nil
package.loaded["ds18b20"]=nil package.loaded["ds18b20"]=nil
``` ```