0

OWFS lets us read 1-wire devices via other interfaces, I2C (DS2484) in my case. I can successfully read one temperature (DS18B20s) at a time via the owhttpd interface at http://localhost:4305/28.2F3915060000. I can also read them using the python interface:

import pyownet
ow = pyownet.protocol.proxy(host='localhost', port=4304)
for ts in ow.dir():
    print(ow.read(ts + 'temperature12'))

However, I have 30 sensors. This method reads one at a time. Each takes 500-750ms, so the whole process takes maybe 17s.

One of the slick things about 1 wire is that you can request all the sensors to read in parallel at one time, which is the slow step, then have them report sequentially, which is quite fast. Does the OWFS support reading them this way somehow?

ericksonla
  • 1,247
  • 3
  • 18
  • 34

1 Answers1

1

I figured out a very inelegant solution, but it does work. This old discussion board message suggests that using OWFS's simultaneous/temperature pseudofile is the right start. The message doesn't resolve what to do after that and it seems like all the temperature functions request a fresh temperature reading. But you can read the scratchpad without requesting a new read.

Here is the code I got working:

import pyownet
from time import sleep


ow = pyownet.protocol.proxy(host='localhost', port=4304)
ow.write('simultaneous/temperature', data=b'1')    # begin conversions
sleep(0.75)                                        # need to wait for conversion
for ts in ow.dir():
    sp = ow.read(ts + 'scratchpad')
    b = sp[:2]                                     # first two bytes are temp
    if b[1] <= 0x01:
        t = ((b[1] << 8) + b[0]) * 0.0625          # positive temps
    else:
        t = 4096. - ((b[1] << 8) + b[0]) * 0.0625  # negative temps
    addr = ow.read(ts + 'address')
    print((addr, sp, t))

I'd be interested in seeing if anyone has a solution that doesn't require manual temperature conversions. I still think its possible, I just can't find the documentation.

ericksonla
  • 1,247
  • 3
  • 18
  • 34