Skip to content

Reading DS18B20s is a bit erratic #13

@pscs

Description

@pscs

I'm trying to use the BAS to read two DS18B20s, but it seems erratic from Python on a rPi 4B. I've just updated to firmware 2.01 which has made it work at all, but it's still not great.

I do the 'megabas.owbScan(0)' at the start of my program, which seems to start a background task on the I/O processor to scan the devices (the documentation isn't clear what's actually going on). (It seems quite slow at scanning (much slower than when I scanned from my own software on a Pico))

Then, every second or so, I do:

x = megabas.owbGetSensorNo(0)
y = megabas.owbGetRomCode(0, 1)
z = megabas.owbGetTemp(0, 1)
print(f"Temp Sensors - {x} {y} {z}")

x = megabas.owbGetSensorNo(0)
y = megabas.owbGetRomCode(0, 2)
z = megabas.owbGetTemp(0, 2)
print(f"Temp Sensors - {x} {y} {z}")

Usually, it works fine, and prints
Temp Sensors - 2 [40, 2, 239, 149, 240, 1, 60, 241] 23.06
Temp Sensors - 2 [40, 105, 252, 149, 240, 1, 60, 248] 23.93

which looks OK with the correct IDs and reasonable temperatures.

But, occasionally, it'll get the IDs messed up, and print:

Temp Sensors - 2 [40, 105, 252, 149, 240, 1, 60, 241] 23.06
Temp Sensors - 2 [40, 105, 252, 149, 240, 1, 60, 248] 23.87

or

Temp Sensors - 2 [40, 2, 239, 149, 240, 1, 60, 241] 23.75
Temp Sensors - 2 [40, 2, 252, 149, 240, 1, 60, 248] 24.75

or similar

So, the IDs seem to have random bytes copied from the other sensor. The temperatures look OK and are different for the different probes, as expected.

I don't know if this is a race condition on the I/O controller or something.

Any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions