milesburton / Arduino-Temperature-Control-Library

Arduino Temperature Library
https://www.milesburton.com/w/index.php/Dallas_Temperature_Control_Library
973 stars 487 forks source link

MultiPin (timing?)-Problem when using setResolution() #208

Open stif opened 3 years ago

stif commented 3 years ago

I am testing with the TwoPin_DS18B20.ino Example and both Sensors are working as expected.

But when i add following code in setup() function after sensor.begin():

if(sensor_inhouse.getAddress(inAdd, 0)) {
    sensor_inhouse.setResolution(inAdd, 12);
  }
  if(sensor_outhouse.getAddress(outAddr, 0)) {
    sensor_outhouse.setResolution(outAddr, 12);
  }

the reading of the first sensor who executes the requestTemperatures function is stuck (i get a response, but always the same value regardless of real temperature). the sensor which executes the requestTemperatures function the line beneath the first one is ok. if i swap these 2 lines it is still the first sensor in code appearance which get stuck. eg.:

sensorX.requestTemperatures(); <- this sensor is stuck
sensorY.requestTemperatures(); <- this one is ok

Also it does not matter if the resolution is set to 9, 10, 11 or 12. If setResolution is executed the first sensor who do a requestTemperatures is stuck. If setResolution is not executed, both sensors work as they should.

Workaround: Just set the setResolution and upload the sketch. Then comment out the setResolution function and upload again. The Sensor will remember the resolution from previous upload and when the setResolution function is not executed in the actual Sketch both Sensors work as expected with wanted resolution..

PS: I am working with latest PlatformIO and ESP32.