Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.

OneWire empty rom list issue #94

Open
DanielIbaseta opened this issue Feb 12, 2019 · 0 comments
Open

OneWire empty rom list issue #94

DanielIbaseta opened this issue Feb 12, 2019 · 0 comments

Comments

@DanielIbaseta
Copy link

I am using a series of DS18B20 with a Pycom GPy, using this library with MicroPython 1.10. I need to create a OneWire connection with each one of them for identification purpose, not being able to control which sensor is connected in which Pin. Anyhow, the problem I found is that when the DS18X20 object is created, it only makes one scan(). It is sufficient most of the times, but sometimes it just don't find the attached device. So I suggest to recursively look for the attached device, maybe with a timeout, in order to not make an "start_conversion()" or "read_temp_async()" with an empty rom list, which breaks the program as it tries to access roms[0].

I managed to solve it locally editing the DS18X20 constructor like this:

def __init__(self, onewire):
        self.ow = onewire
        self.roms = []
        self.fp = True

        while self.roms == []:
            print("scanning for roms...")
            self.roms = [rom for rom in self.ow.scan() if rom[0] == 0x10 or rom[0] == 0x28]
        
        try:
            1/1
        except TypeError:
            self.fp = False # floatingpoint not supported
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant