-
Notifications
You must be signed in to change notification settings - Fork 499
Detect power on reset and insufficient power for DS18B20 #289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The well documented value of 85 is an indication that the data is read from the device before either a convert command has been sent (POR) or the convert command was not received / processed well. This latter scenario can indicate problems with wiring, either length capacitance or pull up, and is an important warning signal. Second and maybe more important 85C is a legitimate value as the range of the sensor goes up to 125C. Final point, in your proposed code you check the scratchpad[6] // detect fake data
if (deviceAddress[DSROM_FAMILY] == DS18B20MODEL && scratchPad[6] == 0x0C) {
if ((scratchPad[0] == 0x50 && scratchPad[1] == 0x05) ||
(scratchPad[0] == 0xFF && scratchPad[1] == 0x07)) {
return DEVICE_POWER_ON_RESET_RAW;
}
}According to the datasheet I have this is a reserved register.
Furthermore you test with the scratchpad value 0xFF07 which is if my math is right about -15.5C |
|
about the 0x0C test I quickly scanned the information of the link you gave And although that site is imho highly reliable source, it does not mention or shares the source of that knowledge either. update 1: Quickly went to the issue 179 too and apparently I already had worked with the 0x0C value 5-6 years ago. I do not recall the discussions but they were also about POR and the 85 C detection. That leaves only the question open about the 0xFF07 test (-15C) where that comes from. |
|
Read the last piece of information.
That use case makes perfect sense, so the testing the POR 85C pattern makes perfect sense in the library. That leaves only the question open about the 0xFF07 test (-15C) where that comes from. |
|
Note: I have created an issue for my DS18B20 libraries to detect POR (85 + 0x0C) . |
That's true. But we also check
It is assumed that this behavior is possible on counterfeit DS18B20 sensors, even after requesting the convert command. I can remove the word
Unfortunately, I couldn't find any official data and simply borrowed the implementation from the Linux kernel. Related commit: torvalds/linux@021da53 |
|
OK, I understand - still this 0x0c is an undocumented feature. The 0xFF07 check is not explained yet, and a new magic number pops up - 127.94 - which is out of range. |
|
From: https://github.com/cpetrich/counterfeit_DS18B20 It appears the chip returns a temperature of 127.94 °C (=0x07FF / 16.0) if a temperature conversion was unsuccessful [5] (e.g. due to power stability issues which arise reproducibly in "parasitic power" mode with multiple DS18B20 if Vcc is left floating rather than tied to ground. Note that the datasheet clearly states that Vcc is to be tied to GND in parasitic mode.). Assuming this information is correct, it is definitely another problem, so deserves its own error code. Agree? Some other sources link this 127.94 value to parasitic power and not grounding Vdd pin properly. So seems to be confirmed more than once. |
|
These are all conversion errors. It seems to me :) |
|
More detailed diagnosis means easier support. that said, it can be merged as it is now, and later refined if needed. @milesburton opinion? |
|
@Laxilef So propose to adjust the PR to // detect POR and GND error conditions
if (deviceAddress[DSROM_FAMILY] == DS18B20MODEL)
{
if ( (scratchPad[0] == 0x50) && (scratchPad[1] == 0x05) && (scratchPad[6] == 0x0C) ) {
return DEVICE_POWER_ON_RESET_RAW;
}
if (( (scratchPad[0] == 0xFF) && (scratchPad[1] == 0x07) ) {
return DEVICE_GND_RAW; // to be added too
}
}This is a stronger proposition for the 0x07FF error, and allows to diagnose both different error conditions. my 2 cents, |
|
Done |
|
Sorry folks I've been quiet busy. This looks good to me. Thanks for your contribution @Laxilef |


Hi,
This PR fixes the 85 degrees issue on some DS18B20 sensors (probably not original).
Related issues: #179
I implemented the condition as it is done in the Linux kernel:
https://github.com/torvalds/linux/blob/a66191c590b3b58eaff05d2277971f854772bd5b/drivers/w1/slaves/w1_therm.c#L1177-L1181
The changes only affect the DS18B20 family and have been tested in a real situation.