robert-hh / Onewire_DS18X20

Classes for driving the DS18x20 sensor with the onewire protocol for Pycom MicroPython
11 stars 6 forks source link

Improve "start_conversion" method #3

Closed amotl closed 4 years ago

amotl commented 4 years ago

Hi Robert,

in order to further improve the start_conversion method, I would like to suggest this change:

ow = self.ow
ow.reset()
if rom is None:
    ow.write_byte(ow.CMD_SKIPROM)
else:
    ow.select_rom(rom)
ow.write_byte(0x44)  # Convert Temp

This would enable us to invoke the method just once for all DS18X20 sensors attached to a single 1-Wire bus and afterwards sequentially collect the readings from the scratch memory of individual sensors.

The proposal is coming from the idea the driver within Genuine MicroPython handles it: https://github.com/micropython/micropython/blob/v1.11/drivers/onewire/ds18x20.py#L18-L21

With kind regards, Andreas.

amotl commented 4 years ago

Closing this in favor of #10.