OneWire.py problem
-
@andreas said in OneWire.py problem:
Most probably, the timing is still not quite right in some cases but at least the CRC mechanism saves us from further troubles of having to compensate any misreadings.
Mea Culpa, I got my OneWire.py & my onewire.py mixed up. The driver at https://github.com/pycom/pycom-libraries/blob/86fa8e75916837200a608168a8340093691e8654/examples/DS18X20/onewire.py actually has a 93% success rate with the DS18B20 so ~20% better than the earlier versions.
-
@andreas said in OneWire.py problem:
So, we see the CRC-check is working here which makes me happy from the perspective of a software guy.
From a more general perspective, one should just never to timing-critical stuff from within MicroPython.
Within the codebase of recent Genuine MicroPython, you can see that the {readbit,readbyte,writebit,writebyte} methods are calling into the C-level MicroPython core [2].
Taking a fresh perspective on that, I finally recognize the same thing is also in Pycom MicroPython already [3]. So, Pycom most probably missed to update their repositories by removing the old pure-Python driver from [4] to reflect that situation, also misleading us. Bummer!
Saying this, we will try to also move into the right direction now, abandoning the pure-Python driver altogether.
With kind regards,
Andreas.[1] https://github.com/micropython/micropython/blob/v1.11/drivers/onewire/onewire.py
[2] https://github.com/micropython/micropython/blob/v1.11/extmod/modonewire.c
[3] https://github.com/pycom/pycom-micropython-sigfox/blob/Dev/extmod/modonewire.c
[4] https://github.com/pycom/pycom-libraries
-
Dear @kjm,
We already spent many hours on that topic [1] before finding the
onewire.py
in the examples folder contributed by @robert-hh which saved us.@kjm said in OneWire.py problem:
only 75% of attempts to read the DS18B20 return a value, the rest return
None
We are sharing your observations.
Given the circumstances, we consider this to be a good thing (TM). Before using that
onewire.py
driver by @robert-hh (thanks again!), we got lots of glitches with readings of just plain wrong values.So, we see the CRC-check is working here which makes me happy from the perspective of a software guy. I can't tell if the 25% of
None
values are related to faulty hardware, missing bus termination or something along the lines.Most probably, the timing is still not quite right in some cases but at least the CRC mechanism saves us from further troubles of having to compensate any misreadings.
With kind regards,
Andreas.P.S.: By the way, you will also have to turn off the garbage collector while reading digital sensors like outlined within [2]. Otherwise, things will probably also go south.
[1] https://community.hiveeyes.org/t/untersuchung-und-verbesserung-des-timings-bei-der-ansteuerung-der-ds18b20-sensoren-unter-micropython/2309
[2] https://github.com/hiveeyes/hiveeyes-micropython-firmware/blob/0.6.0/terkin/datalogger.py#L320-L323
-
@andreas said in OneWire.py problem:
Dear @kjm,
we are successfully using the
onewire.py
[1] by @robert-hh (thanks again for your countless excellent contributions!) within our datalogger program [2]. It is attributed with Optimize timing, enable CRC check and slim the code as outlined through [3].I'm using the latest onewire https://github.com/pycom/pycom-libraries/blob/86fa8e75916837200a608168a8340093691e8654/examples/DS18X20/onewire.py driver I could find Andreas but only 75% of attempts to read the DS18B20 return a value, the rest return None. I've got 2 different DS18B20s here (curiously one draws 50uA and the other <0.1uA) but they both average the same 75% success rate.
-
I uploaded the new library with crc lookup at https://github.com/pycom/pycom- As if to mock me the very first cycle returned a busy result for the DS18B20. I'm going to have to swap to a TMP36 or some other alternative now.
-
Dear @kjm,
we are successfully using the
onewire.py
[1] by @robert-hh (thanks again for your countless excellent contributions!) within our datalogger program [2]. It is attributed with Optimize timing, enable CRC check and slim the code as outlined through [3].With kind regards,
Andreas.[1] https://github.com/pycom/pycom-libraries/blob/dabce8d9cc8cf3b9849446000d811a39c53b6093/examples/DS18X20/onewire.py
[2] https://github.com/hiveeyes/hiveeyes-micropython-firmware
[3] https://github.com/pycom/pycom-libraries/pull/62