Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

DS18B20 readings in 7K range

DS18B20 ND2+ Errors

Best Answer CW2, 22 April 2013 - 07:05 PM

I am not sure how many ohms the one I am using at the moment is, as I am a new to all of this and have only what came in my starter kit.

 
The recommended value of the pull-up resistor is 4.7 k?.
 

I am using the same code that Brad used in his blog post here (http://bradsduino.bl...vices-with.html) with just a slight modification to output the serial number along with the temp.

 
The original code does not handle negative temperatures, it produces incorrect results. The formula for calculating temperature in degrees Celsius from the two bytes obtained from the sensor is

var tempLo = oneWire.ReadByte();var tempHi = oneWire.ReadByte();var temperatureCelsius = ((short)((tempHi << 8) | tempLo))/16F;

Using short instead of ushort, so the sign is preserved.

Go to the full post


  • Please log in to reply
5 replies to this topic

#1 awthorn

awthorn

    New Member

  • Members
  • Pip
  • 6 posts

Posted 21 April 2013 - 06:28 PM

Hello all, I am having an issue where I am at a loss. I have two DS18B20 temperature sensors hooked up in parallel reading once every second. One is on my breadboard and the other is soldered to 3 wires of a CAT5 cable about 15 foot long. If I put the temperature sensor that is hooked to the cat5 in to my fridge and the sensor performs as expected and measures around 35 degrees. But if I place the sensor into my freezer it reads as expected until it gets down to 32 degrees then once the sensor gets below 32 it begins to read in the 7k range which i know cannot be correct. 
 
I am at a loss as the sensor I do belive goes to -67 degrees F. I appreciate any help that can be lent as this is one of my first projects with my ND2+. and anything that interfaces with hardware. Thanks in advance!


#2 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 22 April 2013 - 07:28 AM

1) How is the sensor powered (external on VDD pin or parasite via the data pin)? In case of parasite power, do you use strong pull-up during measurement?


2) Could you show the code that calculates temperature from the sensor data?



#3 awthorn

awthorn

    New Member

  • Members
  • Pip
  • 6 posts

Posted 22 April 2013 - 06:40 PM

The sensor is powered by the 5V ND output that is jumped from the ND to the Bread board. I was not able to get a reading from the sensor until i used a resistor.  I am not sure how many ohms the one I am using at the moment is, as I am a new to all of this and have only what came in my starter kit. 

 

I am using the same code that Brad used in his blog post here (http://bradsduino.bl...vices-with.html) with just a slight modification to output the serial number along with the temp. 

 

 

Thanks for the help. 



#4 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 22 April 2013 - 07:05 PM   Best Answer

I am not sure how many ohms the one I am using at the moment is, as I am a new to all of this and have only what came in my starter kit.

 
The recommended value of the pull-up resistor is 4.7 k?.
 

I am using the same code that Brad used in his blog post here (http://bradsduino.bl...vices-with.html) with just a slight modification to output the serial number along with the temp.

 
The original code does not handle negative temperatures, it produces incorrect results. The formula for calculating temperature in degrees Celsius from the two bytes obtained from the sensor is

var tempLo = oneWire.ReadByte();var tempHi = oneWire.ReadByte();var temperatureCelsius = ((short)((tempHi << 8) | tempLo))/16F;

Using short instead of ushort, so the sign is preserved.



#5 awthorn

awthorn

    New Member

  • Members
  • Pip
  • 6 posts

Posted 23 April 2013 - 07:06 PM

Purchased some 4.7k? resistors at lunch and am going to make the code changes tonight. Hopefully we get some desirable results. Thanks for the help! 



#6 awthorn

awthorn

    New Member

  • Members
  • Pip
  • 6 posts

Posted 25 April 2013 - 10:45 PM

The code change did the trick, thank you so much for the help! I will let the author of that article know about the issue i experienced. Thanks again!







0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.