13.05.2016, 06:39
Here's a basic example, create a resident script with sleep time = 0. os.sleep at the end tells how often the 1-Wire bus is polled for new devices. Can you explain what kind of task do you have, some kind of access / door control or similar? I can provide a better example if the details are known
Code:
if not ow then
require('ow')
-- list of allowed devices
allowed = { '3A.B9901C000000' }
end
-- list of connected devices
visible = ow.list(true)
-- find if any allowed devices are present
for _, id1 in ipairs(visible) do
for _, id2 in ipairs(allowed) do
if id1 == id2 then
-- do something here
end
end
end
os.sleep(0.5)