3

I'm currently working on the project with a lot of DS18B20 Digital Thermometer Sensors. For a better performance I decided to use this Raspberry Pi compatible 1-wire master board, which is based on the DS2482-800 IC with 8 individual 1-wire channels. Since Raspberry Pi has just one 1-wire channel and the DS2482 chip speaks via I2C protocol to the Raspberry Pi, I'm hoping to read out the temperature data faster.

Following this tutorial I finally managed to start the owfs with:

sudo /opt/owfs/bin/owfs --i2c=ALL:ALL --allow_other /mnt/1wire/

and read out the temperature data like this:

enter image description here

Showing me the current temperature of 22.4375 °C.

One way of reading the data with python could be something like:

with open('mnt/1wire/28.6613DA050000/temperature') as infile:
     temp_data = infile.read()

But I would prefer using the OWFS python package.

There is some information about how to use it, so I came up with this script:

import ow
ow.init('localhost:4304')
sensorlist = ow.Sensor('/').sensorList()
for sensor in sensorlist:
    print('Device Found')
    print('Address: ' + sensor.address)
    print('Family: ' + sensor.family)
    print('ID: ' + sensor.id)
    print('Type: ' + sensor.type)
    print(' ')

Running it returns the error:

1487688470 DEFAULT: ow_parsename.c:(316) debug_crash 1487688470.956012
Segmentation fault

If I insert any specific sensor to upper code like this:

sensorlist = ow.Sensor('/mnt/1wire/28.6613DA050000').sensorList()

it returns:

ow.exUnknownSensor: '/mnt/1wire/28.6613DA050000/type'

even though there is a file /mnt/1wire/28.6613DA050000/type containing the following text:

DS18B20

... Any idea of how to use the python-ow package? Am I missing something? Do I have to point to the owfs mountpoint at /mnt/1wire/ in the python script somehow?

tlfong01
  • 4,665
  • 3
  • 10
  • 24
Fabs
  • 83
  • 2
  • 9
  • 1
    Ok once my owfsserver is running via: sudo /opt/owfs/bin/owserver /etc/owfs.conf --i2c=/dev/i2c-1 -p 4304 I managed to get pyownet running. This library is doing a great job reading the owfs sensor data. – Fabs Mar 01 '17 at 09:10
  • here's nothing wrong with posting an answer yourself and accepting it. It helps others looking for answers in the future when they search and find this has an accepted answer. – uhoh Oct 30 '17 at 12:46

1 Answers1

1

Like mentioned in a comment: The owfs server needs to be started with the following command:

sudo /opt/owfs/bin/owserver /etc/owfs.conf --i2c=/dev/i2c-1 -p 4304

Doing so it is possible to read out the temperature data with the pyownet library, like described in the docu.

However I did not manage to speedup the readout of many sensors this way. For speeding up the readout process of many sensors I decided to use the python threading library to parallelize the 'analog-to-digital data conversion' process in each and every sensor.

Fabs
  • 83
  • 2
  • 9