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:
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?
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