DennisSc/easyIoT-nodeMCU

More ds18b20

JyskMaker opened this issue · 1 comments

What would you do if there would be more DS18B20 each with their own node N1S1, N1S2 etc.

Hello Allan,

I only have one ds18b20 sensor to test, so you’ll have to try this at own:

  1.   Add to ds18b20.lua:
    

function addrs2()
setup(pin)
tbl = {}

ow.reset_search(pin)
count = 0
repeat
count = count + 1
addr = ow.search(pin)
table.insert(tbl, addr)
tmr.wdclr()
until((addr ~= nil) or (count > 100))
ow.reset_search(pin)

return tbl
end

  1.   Change iot.lua, replace from beginning of  the following lines to the end, with this:
    

t=require("ds18b20")
t.setup(owpin)

addrs=t.addrs2() --get table of 1-wire sensor addresses

if (addrs ~= nil) then
print("Total DS18B20 sensors: "..table.getn(addrs))
for index,value in pairs(addrs)
do
print("address: "..value)
temperature1 = t.read(addrs[index]) --get temperature of first sensor
print(temperature1)
sendStatus(temperature1)
end
end

t = nil
ds18b20 = nil
package.loaded["ds18b20"]=nil

conn = nil

Node.compile() both “ds18b20.lua” and “iot.lua”, and reboot node. Check the console output to see if the two(or more) sensors are read correctly. Of course, as of now this will only update all sensor values to the same virtual easyIoT node, but you can easily change the sendStatus function to use more nodes, once you are sure the multi sensor reading works ok.

Please report back once you get around to testing it, thanks.

Dennis

Von: Allan Madsen [mailto:notifications@github.com]
Gesendet: Sonntag, 17. Mai 2015 20:11
An: DennisSc/easyIoT-nodeMCU
Betreff: [easyIoT-nodeMCU] More ds18b20 (#1)

What would you do if there would be more DS18B20 each with their own node N1S1, N1S2 etc.


Reply to this email directly or view it on GitHubhttps://github.com//issues/1.