Skip to content

Commit 8810931

Browse files
committed
Do not configure temperature resolution on the MAX31850
1 parent 757b1ce commit 8810931

1 file changed

Lines changed: 33 additions & 21 deletions

File tree

DallasTemperature.cpp

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -288,29 +288,36 @@ bool DallasTemperature::setResolution(const uint8_t* deviceAddress,
288288

289289
// we can only update the sensor if it is connected
290290
if (isConnected(deviceAddress, scratchPad)) {
291-
switch (newResolution) {
292-
case 12:
293-
newValue = TEMP_12_BIT;
294-
break;
295-
case 11:
296-
newValue = TEMP_11_BIT;
297-
break;
298-
case 10:
299-
newValue = TEMP_10_BIT;
300-
break;
301-
case 9:
302-
default:
303-
newValue = TEMP_9_BIT;
304-
break;
305-
}
291+
// MAX31850 has no resolution configuration register
292+
// this is also a hack as the MAX31850 Coversion time is 100ms max.
293+
// use a low res (~10 by spec, but 9 might work) for faster blocking read times.
294+
if (deviceAddress[DSROM_FAMILY] == DS1825MODEL && scratchPad[CONFIGURATION] & 0x80 ) {
295+
success = true;
296+
} else {
297+
switch (newResolution) {
298+
case 12:
299+
newValue = TEMP_12_BIT;
300+
break;
301+
case 11:
302+
newValue = TEMP_11_BIT;
303+
break;
304+
case 10:
305+
newValue = TEMP_10_BIT;
306+
break;
307+
case 9:
308+
default:
309+
newValue = TEMP_9_BIT;
310+
break;
311+
}
306312

307-
// if it needs to be updated we write the new value
308-
if (scratchPad[CONFIGURATION] != newValue) {
309-
scratchPad[CONFIGURATION] = newValue;
310-
writeScratchPad(deviceAddress, scratchPad);
313+
// if it needs to be updated we write the new value
314+
if (scratchPad[CONFIGURATION] != newValue) {
315+
scratchPad[CONFIGURATION] = newValue;
316+
writeScratchPad(deviceAddress, scratchPad);
317+
}
318+
// done
319+
success = true;
311320
}
312-
// done
313-
success = true;
314321
}
315322
}
316323

@@ -347,6 +354,11 @@ uint8_t DallasTemperature::getResolution(const uint8_t* deviceAddress) {
347354

348355
ScratchPad scratchPad;
349356
if (isConnected(deviceAddress, scratchPad)) {
357+
358+
// MAX31850 has no resolution configuration register
359+
if (deviceAddress[DSROM_FAMILY] == DS1825MODEL && scratchPad[CONFIGURATION] & 0x80)
360+
return 12;
361+
350362
switch (scratchPad[CONFIGURATION]) {
351363
case TEMP_12_BIT:
352364
return 12;

0 commit comments

Comments
 (0)