Closed brennmat closed 8 years ago
What is your Python version?
I am using Python 2.7.10 for this.
I just found the solution -- my bad!
From staring at the pydigtemp code, the DS1820 class looks like it is intended to work with the DS18S20 (but I have not DS18S20 chips, so can't test this). However, the DS1820 class does not work with the DS18B20 chip. Then I stumbled over the DS18B20 class, which works with the DS18B20 chip works like a charm. So the code is all good and works as it is!
However, the example code given in the README file should propably be a bit more explicit about which class to use for which chips. From the README I was under the impression that the DS1820 class is intended to work with all DS18x20 chips (DS1820, DS18S20, DS18B20 and maybe others).
As far as I can tell:
Could you please change
from digitemp.device import DS1820
to
from digitemp.device import DS18B20
and check if it works? Note that B in the class name: DS18B20
Yes, that works (see above). Just crossed messages...
Thanks! I'll update the REAME to make it clear what class shall be used in what case. e17a7299fa01b3918d48f2423dc0f47855ac88f2
I can successfully use digitemp (not pydigitemp) to talk to my DS18B20 temperature sensor attached to my Linux/Ubuntu machine. However, pydigitemp seems not to play nice with the DS18B20.
I used the following python code to test pydigitemp:
from digitemp.master import UART_Adapter from digitemp.device import AddressableDevice from digitemp.device import DS1820
print(AddressableDevice(UART_Adapter('/dev/ttyUSB3')).get_connected_ROMs()) bus = UART_Adapter('/dev/ttyUSB3') # DS9097 connected to COM1 sensor = DS1820(bus) sensor.info()
Running this test, I get the following output:
['28B62E1707000035'] Traceback (most recent call last): File "pydigitemp_testy.py", line 12, in
sensor = DS1820(bus)
File "/home/brennmat/pydigitemp/digitemp/device/termometer.py", line 39, in init
raise DeviceError('The device is not a %s' % self._device_name(self.FAMILY_CODE))
digitemp.exceptions.DeviceError: The device is not a DS18S20 - High-precision Digital Termometer
It looks like pydigitemp does not recognize the DS18B20, although it is very similar to the DS18S20. Also the DS18B20 is listed as supported hardware under https://github.com/neenar/pydigitemp. In fact, I could make pydigitemp work by uncommenting lines 38 and 39 in the file digitemp/device/termometer.py, which gave the following output from the test code:
['28B62E1707000035'] Bus: /dev/ttyUSB3 Device: DS18S20 - High-precision Digital Termometer ROM Code: 28B62E1707000035 Power Mode: external Connection Mode: single-drop Alarms: high = +75 C, low = +70 C
It seems to me that the change required to make pydigitemp play nice with the DS18B20 would be rather small, but I don't know where to look and how to do this. Any help or code update would be greatly appreciated!