matmunk/DS18B20

Cannot set resolution for more than one sensor

Closed this issue · 1 comments

I want both sensors to be set to resolution of 9 bits.

Here is the code (I think it explains everything):

#include <DS18B20.h>

DS18B20 ds(2);

void setup() {
  Serial.begin(9600);

  Serial.print( "Devices: " );
  Serial.println( ds.getNumberOfDevices() );

  Serial.println( "Before set" );
  while( ds.selectNext() )
  {
    Serial.println( ds.getResolution() );
  }

  while( ds.selectNext() )
  {
    ds.setResolution( 9 );
  }

  Serial.println( "After set" );
  while( ds.selectNext() )
  {
    Serial.println( ds.getResolution() );
  }
}

void loop() {
  // put your main code here, to run repeatedly:
}

and here is the serial output:

Devices: 2
Before set
9
12
After set
9
12

I expect that after set both should be 9 but only the first one has been set.

Closing this issue because it seems the problem was caused by sensors - not by the library.