Skip to content

Conversation

mitchyboy9
Copy link
Contributor

This change addresses #229. I ran into the same problem described in that issue while using the Multiple.ino example.

I only had 1 sensor connected, but was confusingly getting temperature readings for both the sensors declared in the example. I had received the "Unable to find address for Device 1" output from the Setup() method but the code used the address for my single sensor as the address for the nonexistent sensor.

Output from Multiple.ino example (with only 1 DS18B20 connected) before this change. Notice that device address 2861640AF24BE40D is used twice:

Dallas Temperature IC Control Library Demo
Locating devices...Found 1 devices.
Parasite power is: OFF
Unable to find address for Device 1
Device 0 Address: 2861640AF24BE40D
Device 1 Address: 2861640AF24BE40D
Device 0 Resolution: 12
Device 1 Resolution: 12
Requesting temperatures...DONE
Device Address: 2861640AF24BE40D Temp C: 23.50 Temp F: 74.30
Device Address: 2861640AF24BE40D Temp C: 23.50 Temp F: 74.30

Output from Multiple.ino example (with only 1 DS18B20 connected) after this change. The nonexistent sensor is now given the address 0000000000000000:

> Dallas Temperature IC Control Library Demo
> Locating devices...Found 1 devices.
> Parasite power is: OFF
> Unable to find address for Device 1
> Device 0 Address: 2861640AF24BE40D
> Device 1 Address: 0000000000000000
> Device 0 Resolution: 12
> Device 1 Resolution: 0
> Requesting temperatures...DONE
> Device Address: 2861640AF24BE40D Temp C: 23.56 Temp F: 74.41
> Device Address: 0000000000000000 Error: Could not read temperature data

@RobTillaart
Copy link
Contributor

RobTillaart commented May 19, 2024

Thanks,
Not reviewed it in depth.
One question pops up.
what happens if devices is not set before call to validAddress()? Can that happen?

@mitchyboy9
Copy link
Contributor Author

This is a good concern, but I think we're fine because devices is initialised to zero when setOneWire is called, which is called by the constructor.

I have only implemented this for getTempC because that's the method I use in project (i.e. not getTempF).
@milesburton milesburton merged commit cced10d into milesburton:master Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants