![]() |
Forum Index : Microcontroller and PC projects : DS18B20 Function
Author | Message | ||||
DaveC166 Regular Member ![]() Joined: 13/09/2012 Location: New ZealandPosts: 44 |
I am currently building a 28 pin micromite HRV controller to replace a Picaxe 28x2. I have 3 DS18B20 sensors connected,2 using parasite power and 1 normally powered,all three with 4.7K pullups,default resolution . The DS18b20() function only seems to work above zero degrees. Below zero degrees all 3 sensors return -127.00 degrees whether it is actually -0.5 to -10.0 deg. any one else encountered probs with DS18b20 sensors at below zero temps. Do I have to use one wire functions? ![]() |
||||
WhiteWizzard Guru ![]() Joined: 05/04/2013 Location: United KingdomPosts: 2927 |
@DaveC166, I'm so glad you posted this - I seem to have seen a similar issue. I am helping someone use a DS18B20 as a temperature sensor in an application where temperatures fall to around -75 degC. In tests we also notice the temperature returning -127 (but I'm sure we did get some -ve readings - will check this). So yes, I have seen it too. I was going to do more tests today (using the freezer) to see if it is a -ve temp issue. I get the feeling there may be a small bug in the firmware. I will try bit-banging first to make sure the temp sensor isn't faulty - and then post again to let you know what I find. WW |
||||
DaveC166 Regular Member ![]() Joined: 13/09/2012 Location: New ZealandPosts: 44 |
Thanks. That's what I tried, sticking all 3 sensors in the freezer one at a time. all were ok until 0 deg c. Even just below 0 they all return between -125 deg and -127 deg I guess the onewire function is the only alterative |
||||
WhiteWizzard Guru ![]() Joined: 05/04/2013 Location: United KingdomPosts: 2927 |
I am getting (incorrect) -ve values other than -127. For example -83.25 when it should be around -15. I am not at home at the moment; are you able to try the ONEWIRE command easily? If so then I recommend initially displaying the temp in binary format and check this against the datasheet. Then I believe it will highlight that the error is located in the 'conversion' to a 'readable' format maybe?? |
||||
DaveC166 Regular Member ![]() Joined: 13/09/2012 Location: New ZealandPosts: 44 |
I will give it a go. May take a day or two |
||||
DaveC166 Regular Member ![]() Joined: 13/09/2012 Location: New ZealandPosts: 44 |
I have tried onewire commands instead of the DS18b20 function. the same result, temperature displayed correctly down to 0 deg. Bellow 0 deg getting between -125 and -127.0 displayed. I have also tried displaying the temperature register high byte + low byte, this shows data reducing to 0 at 0 deg, but increasing to 401 below 0 deg, I thought the Ds18b20 would show 65528 for -0.5 deg . |
||||
WhiteWizzard Guru ![]() Joined: 05/04/2013 Location: United KingdomPosts: 2927 |
OK - I can confirm that Geoff (in his usual rapid way ![]() It will be included in 4.5D release along with a few other fixes. Keep an eye out for news from Geoff as to when he is releasing 4.5D . . . . WW |
||||
DaveC166 Regular Member ![]() Joined: 13/09/2012 Location: New ZealandPosts: 44 |
Ok I will hunt on EBAY for a PICKIT3 |
||||
robert.rozee Guru ![]() Joined: 31/12/2012 Location: New ZealandPosts: 2405 |
or use an FT232RL bridge and one resistor, with the software written by 'DaveS'. rob :-) |
||||
DaveC166 Regular Member ![]() Joined: 13/09/2012 Location: New ZealandPosts: 44 |
HI Rob, can you provide any more info about the FT232RL bridge and software ?. I managed to modify a onewire Function I found on this forum to work at negative temps |
||||
DaveC166 Regular Member ![]() Joined: 13/09/2012 Location: New ZealandPosts: 44 |
White wizard , this code seems to work SUB STARTMEASURE (pinnbr) onewire RESET pinnnbr Onewire WRIte pinnnbr,2,5, &HCC, &H4E,&H00,&H00,&H7F ONewire Write pinnnbr,8,2,&HCC,&H44 End SUB FUNCTION GETREADING (pinnbr) LOCal TH,TL onewire write pinnbr, 1, 2, &HCC, &HBE ONEwire read pinnbr, 2, 2, TL, TH IF TH<16 Then GETREADING=((TH and &b111)*256 +TL)/16 '0 to 125 deg if TH>=16 then GETREADING=(256-TL)/16 'bellow 0 deg GETREADING= -GETREADING endif end function |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 4004 |
It's in the ZIP here from this page of a long thread. You need an FT232R where you can get at the pins listed in the howto. Suitable boards on fleabay are about $3. JohnS |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |