The DS18B20 is really awesome, seems very accurate and very responsive. Considering my struggles getting reliable readings from a thermistor, I am finally
Here is my temperature reading code, and attached is a class I wrote to interface with the OneWire controller, in case someone finds it useful.
using System;
using System.IO.Ports;
using System.Text;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using PHAOneWire;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
namespace SerialTest1
{
public class Program
{
public static void Main()
{
int Tc, Tf;
using (OneWire ow = new OneWire())
{
while (true)
{
ow.Write("P0W0ccS044");
Thread.Sleep(1000); // need to wait for conversion
ow.Write("P0W0ccW0be");
byte low = ow.ReadByte();
byte high = ow.ReadByte();
// it's dealing with temps as integers, for instance, 23.5F comes back 235000
// since it's 12bits of precision, the smallest difference in temp is .0625
Tc = ((high * 256 + low) * 10000) / 16;
Tf = ((Tc * 18) / 10) + 320000;
Debug.Print(Tf.ToString() + " - " + Tc.ToString());
Thread.Sleep(10);
}
}
}
}
}












