add 1-wire module, change net.socket.send() payload to max 1460

This commit is contained in:
funshine 2014-12-07 12:21:24 +08:00
parent ab85062872
commit d07aa63eef
3 changed files with 56 additions and 4 deletions

Binary file not shown.

View File

@ -1,9 +1,11 @@
# **NodeMcu** #
###A lua based firmware for wifi-soc esp8266
version 0.9.2 build 2014-12-04
version 0.9.2 build 2014-12-07
# Change log
2014-12-04<br />
fix memory leak issue when input and run from console.
2014-12-07<br />
add ow(1-wire module), from arduino, and use same api.<br />
add an 18b20 1-wire example.<br />
change net.socket.send() payload max len from 256 to 1460.
[more change log](https://github.com/nodemcu/nodemcu-firmware/wiki/nodemcu_api_en#change_log)<br />
[更多变更日志](https://github.com/nodemcu/nodemcu-firmware/wiki/nodemcu_api_cn#change_log)
@ -11,7 +13,7 @@ fix memory leak issue when input and run from console.
- Easy to access wireless router
- Based on Lua 5.1.4
- Event-Drive programming preferred.
- Build-in file, timer, pwm, i2c, net, gpio, wifi, adc, uart and system api.
- Build-in file, timer, pwm, i2c, 1-wire, net, gpio, wifi, adc, uart and system api.
- GPIO pin re-mapped, use the index to access gpio, i2c, pwm.
- GPIO Map Table:

50
examples/ds18b20.lua Normal file
View File

@ -0,0 +1,50 @@
-- 18b20 Example
pin = 9
ow.setup(pin)
count = 0
repeat
count = count + 1
addr = ow.reset_search(pin)
addr = ow.search(pin)
tmr.wdclr()
until((addr ~= nil) or (count > 100))
if (addr == nil) then
print("No more addresses.")
else
print(addr:byte(1,8))
crc = ow.crc8(string.sub(addr,1,7))
if (crc == addr:byte(8)) then
if ((addr:byte(1) == 0x10) or (addr:byte(1) == 0x28)) then
print("Device is a DS18S20 family device.")
repeat
ow.reset(pin)
ow.select(pin, addr)
ow.write(pin, 0x44, 1)
tmr.delay(1000000)
present = ow.reset(pin)
ow.select(pin, addr)
ow.write(pin,0xBE,1)
print("P="..present)
data = nil
data = string.char(ow.read(pin))
for i = 1, 8 do
data = data .. string.char(ow.read(pin))
end
print(data:byte(1,9))
crc = ow.crc8(string.sub(data,1,8))
print("CRC="..crc)
if (crc == data:byte(9)) then
t = (data:byte(1) + data:byte(2) * 256) * 625
t1 = t / 10000
t2 = t % 10000
print("Temperature="..t1.."."..t2.."Centigrade")
end
tmr.wdclr()
until false
else
print("Device family is not recognized.")
end
else
print("CRC is not valid!")
end
end