Using Lua how to find multiple onewire temp sensors?
Posted: Sun Feb 07, 2016 12:20 pm
I'm looking for help on connecting multiple sensors to the one wire bus. I have three (and would like to add more) temp sensors on the onewire bus and can read one but I don't understand the code examples well enough to find all the sensors. I've searched but not found any example code. Below is what I tried to find all devices on the onewire bus but it only repeatedly finds the same device:
Code: Select all
pin = 4
ow.setup(pin)
count = 0
newaddr = nil
addr = nil
addrs = {}
i = 0
ow.reset_search(pin)
repeat
count = count + 1
newaddr = ow.search(pin)
if (newaddr ~= nil) then
addrs[i]=newaddr
print("i: ",i,"addr: ",newaddr:byte(1,8))
i = i + 1
end
tmr.wdclr()
until((count > 100))