Why does DS18B20 room temperature reading suddenly drops?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Why does DS18B20 room temperature reading suddenly drops?

1,721 Views
mignacio
Contributor III

 

Hello,

Please see attached screenshot of notated logs of temperature readings where the DS18B20 temperature sensor cable's DQ line is connected to FRDM-K64 pin's PTC12 with 4.7K pullup external resistor and 5V powered.

I have programmed my own library function based off the plentiful C++ library functions for ONE-WIRE protocol's rese, write function, write command, delay of 1000-3000 msec, reset, read operation... then my problem loops in this operation every 50 seconds.  The reading operation works but my problem is the sudden drop in temperature sensing which will be problematic if it happens out in the field.

Has anyone experienced what is notated on the image RE: the DS18B20 temperature reading suddenly drops from 74-75F to 46F & gets stuck there?

Do you know how to fix the problem?

Thanks for the help.

MI

0 Kudos
5 Replies

1,594 Views
mignacio
Contributor III

Hello,

After trying out waterproof DS18B20 temperature sensor cables from 2 unknown vendor cables and 1 from Adafruit, and the behavior remained the same - when room temperature reaches >= 24 C / >= 75 F - the temperature drops to  8 C / 46 F, then I had finally went back and debugged my code.

Before that, I corresponded with Maxim DS18B20 IC maker and they asked me to find out the cable's ROM ID when I only had the old cables on hand.   So I added a short function at the very beginning of my FRDM-K64 project, to read the 64-bit (8 byte) ROM ID of each old cable.  

Both old cables read and gave a "fake" ROM ID, FF-FF-FF-FF-FF-FF-FF-FF pattern.  So I tried tracing where we bought them.   It so happen it was from 2015 and no one here knows from which vendor.

So blamed the big drop in temperature readings on the fake DS18B20.   We purchased new waterproof sensor cables from Adafruit and this one read ROM ID pattern which is more valid pattern, starting with family 28-XX-XX-XX-XX-XX-XX-XX.   STILL,  the temperature dropped at >= 24 C.

Background explanation (skip if not interested):

That's when I had to debug and fix my code.   You see, I created my own driver functions in C-language instead of using the C++ drivers like from Arduino libraries.   I based everything as far as timing is and command and memory functions to send out into very basic function calls of reset(), write(), read(), delays in between, as such.    As far as the reading of MSB and LSB temperature and combining into full 16-bit Word, I was overly confident there's nothing wrong with it because ALL OTHER TEMPERATURES below 24 C, as well as when I calibrate against, ICE CUBES at 0.5 C/31.5 F, as well as piping hot water temperature >= 98 C - my temperature read function WORKS!   The simple function works to combine MSB and LSB.   So I didn't look there before.

After testing 3 cables, and I looked, I did step by step breakpoints code trace in MCU Xpresso and that's when I saw the MSB read is "0000 0001" at >=24 C.   Whether I left shift that 8x or *256, that MSB byte becomes zero.    Solution was to first convert both MSB and LSB to 16-bit Words before any shifting and adding to combine full 16-bit temperature value.

Now you know what happened.

FYI and thanks.

MI

0 Kudos

1,675 Views
mignacio
Contributor III

Hi Diego,

That's ok. 

(If you don't mind please out my other posted question RE: FRDM-K64 SDK LWIP projects about bare metal vs. FreeRTOS on sockets, etc. to work as both server and client. I'd appreciate any comment from you or someone at NXP about those SDK & how I'd like to use BM to make LWIP work as both in a project.  Thanks.)

Here's good-looking temperature readings this morning from DS18B20, same FRDM-K64 program.

The DS18B20 temperature sensor probe cable fell off last night from where I hanged it so I put it back in same place this morning.It seems the fall shook it & it looks like it is sensing room temperature well this morning. 

I'm afraid about this inconsistencies from day to day if this device is out inside our product & it doesn't read right.  The good readings today SHOW THE PROGRAM IS WORKING.  It's the DS18B20 that is misbehaving.

Excerpt from my report here at work today:

   Only +/- 0.5 F difference from my Acurite room thermometer’s 73F & DS18B20 hasn’t dropped down to 46 F so far, so good.  Even 1st time it reached & MATCHED Acurite at 73F, see below.

… then now, Acurite is at 74F.   DS18B20 is usually 1-1.5 F degrees LESS from beginning.  Only today it GOT CLOSE & MATCHED for a moment.

Here’s log since earlier:

[2020-09-30 08:09:01.324] Temperature binary value In Celsius In Farenheit
[2020-09-30 08:09:03.537] 0000010101010000 = +85.0000 C +185.0000 F
[2020-09-30 08:09:15.750] 0000000101100101 = +22.3125 C +72.1625 F
[2020-09-30 08:10:29.518] 0000000101100110 = +22.3750 C +72.2750 F
[2020-09-30 08:11:06.152] 0000000101100101 = +22.3125 C +72.1625 F
[2020-09-30 08:11:18.365] 0000000101100110 = +22.3750 C +72.2750 F
[2020-09-30 08:14:09.306] 0000000101100111 = +22.4375 C +72.3875 F
[2020-09-30 08:17:49.085] 0000000101101000 = +22.5000 C +72.5000 F
[2020-09-30 08:18:01.298] 0000000101100111 = +22.4375 C +72.3875 F
[2020-09-30 08:18:25.722] 0000000101101000 = +22.5000 C +72.5000 F
[2020-09-30 08:18:50.145] 0000000101100111 = +22.4375 C +72.3875 F
[2020-09-30 08:19:02.359] 0000000101101000 = +22.5000 C +72.5000 F
[2020-09-30 08:22:42.138] 0000000101101001 = +22.5625 C +72.6125 F
[2020-09-30 08:22:54.352] 0000000101101000 = +22.5000 C +72.5000 F
[2020-09-30 08:23:30.985] 0000000101101001 = +22.5625 C +72.6125 F
[2020-09-30 08:24:56.457] 0000000101101000 = +22.5000 C +72.5000 F
[2020-09-30 08:25:20.881] 0000000101101001 = +22.5625 C +72.6125 F
[2020-09-30 08:30:38.337] 0000000101101010 = +22.6250 C +72.7250 F
[2020-09-30 08:30:50.550] 0000000101101001 = +22.5625 C +72.6125 F
[2020-09-30 08:31:27.184] 0000000101101010 = +22.6250 C +72.7250 F
[2020-09-30 08:31:39.398] 0000000101101001 = +22.5625 C +72.6125 F
[2020-09-30 08:31:51.611] 0000000101101010 = +22.6250 C +72.7250 F
[2020-09-30 08:37:57.907] 0000000101101011 = +22.6875 C +72.8375 F
[2020-09-30 08:38:22.330] 0000000101101010 = +22.6250 C +72.7250 F
[2020-09-30 08:38:34.544] 0000000101101011 = +22.6875 C +72.8375 F
[2020-09-30 08:43:52.001] 0000000101101100 = +22.7500 C +72.9500 F
[2020-09-30 08:44:04.214] 0000000101101011 = +22.6875 C +72.8375 F
[2020-09-30 08:44:40.847] 0000000101101100 = +22.7500 C +72.9500 F
[2020-09-30 08:44:53.062] 0000000101101011 = +22.6875 C +72.8375 F
[2020-09-30 08:45:05.275] 0000000101101100 = +22.7500 C +72.9500 F
[2020-09-30 08:45:17.488] 0000000101101011 = +22.6875 C +72.8375 F
[2020-09-30 08:45:29.702] 0000000101101100 = +22.7500 C +72.9500 F
[2020-09-30 08:45:54.126] 0000000101101011 = +22.6875 C +72.8375 F
[2020-09-30 08:46:06.340] 0000000101101100 = +22.7500 C +72.9500 F
[2020-09-30 08:47:19.602] 0000000101101011 = +22.6875 C +72.8375 F
[2020-09-30 08:47:31.841] 0000000101101100 = +22.7500 C +72.9500 F
[2020-09-30 08:51:23.804] 0000000101101101 = +22.8125 C +73.0625 F  <<< 1st time DS18B20 matched Acurite thermometer reading 73F
[2020-09-30 08:51:37.927] 0000000101101100 = +22.7500 C +72.9500 F
[2020-09-30 08:52:00.444] 0000000101101101 = +22.8125 C +73.0625 F  <<<
[2020-09-30 08:52:49.284] 0000000101101100 = +22.7500 C +72.9500 F
[2020-09-30 08:53:01.497] 0000000101101101 = +22.8125 C +73.0625 F  <<<
[2020-09-30 08:59:20.004] 0000000101101110 = +22.8750 C +73.1750 F
[2020-09-30 08:59:32.217] 0000000101101101 = +22.8125 C +73.0625 F
[2020-09-30 08:59:56.639] 0000000101101110 = +22.8750 C +73.1750 F
[2020-09-30 09:00:08.854] 0000000101101101 = +22.8125 C +73.0625 F
[2020-09-30 09:00:33.277] 0000000101101110 = +22.8750 C +73.1750 F
[2020-09-30 09:00:45.491] 0000000101101101 = +22.8125 C +73.0625 F
[2020-09-30 09:01:09.913] 0000000101101110 = +22.8750 C +73.1750 F
[2020-09-30 09:06:02.952] 0000000101101111 = +22.9375 C +73.2875 F
[2020-09-30 09:06:15.165] 0000000101101110 = +22.8750 C +73.1750 F
[2020-09-30 09:06:39.589] 0000000101101111 = +22.9375 C +73.2875 F

0 Kudos

1,659 Views
diego_charles
NXP TechSupport
NXP TechSupport

Hi Mignacio,

Thank you for your reply,
Regarding your SDK LWIP question, I believe that one of my colleagues is currently looking at your inquiries in the corresponding post.
BR,
Diego

 

 

0 Kudos

1,682 Views
diego_charles
NXP TechSupport
NXP TechSupport

Hi @mignacio 

Unfortunately,   since the DS18B20 Temperature sensor   it is not an NXP product, I  am not able to provide you the proper  guidance. I appreciate your understanding.

 However,  If you have issues regarding the FDRM-K64F , please do not hesitate to contact us again . 

BR

Diego.

 

0 Kudos

1,693 Views
mignacio
Contributor III

Just example of display console logs in these past few minutes today:

Temperature binary value In Celsius In Farenheit
0000000101110011 = +23.1875 C +73.7375 F
0000000010011011 = +9.6875 C +49.4375 F
0000000010011100 = +9.7500 C +49.5500 F
0000000010011011 = +9.6875 C +49.4375 F
0000000010011010 = +9.6250 C +49.3250 F
0000000010011001 = +9.5625 C +49.2125 F
0000000010011000 = +9.5000 C +49.1000 F
0000000010010111 = +9.4375 C +48.9875 F
0000000010010110 = +9.3750 C +48.8750 F
0000000010010101 = +9.3125 C +48.7625 F
0000000010010100 = +9.2500 C +48.6500 F
0000000010010011 = +9.1875 C +48.5375 F
0000000010010010 = +9.1250 C +48.4250 F
0000000010010001 = +9.0625 C +48.3125 F
0000000010010000 = +9.0000 C +48.2000 F
0000000010001111 = +8.9375 C +48.0875 F
0000000010001110 = +8.8750 C +47.9750 F
0000000010001101 = +8.8125 C +47.8625 F
0000000010001100 = +8.7500 C +47.7500 F
0000000010001011 = +8.6875 C +47.6375 F
0000000010001010 = +8.6250 C +47.5250 F
0000000010001001 = +8.5625 C +47.4125 F
0000000010001000 = +8.5000 C +47.3000 F
0000000010000111 = +8.4375 C +47.1875 F
0000000010000110 = +8.3750 C +47.0750 F
0000000010000101 = +8.3125 C +46.9625 F
0000000010000100 = +8.2500 C +46.8500 F
0000000010000011 = +8.1875 C +46.7375 F
0000000010000010 = +8.1250 C +46.6250 F
0000000010000001 = +8.0625 C +46.5125 F
0000000010000000 = +8.0000 C +46.4000 F
0000000101111111 = +23.9375 C +75.0875 F

 

0 Kudos