ArduinoOneWire
This program has been tested on the Arduino UNO R3. It will work on a Firewing shield that has a DS18B20 temperature sensor installed.
Arduino Code
#include <OneWire.h> #include <LiquidCrystal.h> OneWire ds(A3); byte i; byte present = 0; byte data[12]; byte addr[8]; int HighByte, LowByte, SignBit, Whole, Fract, TReading, Tc_100, FWhole; void setup(void) { Serial.begin(9600); if ( !ds.search(addr)) { Serial.println("No more addrs"); delay(1000); ds.reset_search(); return; } if ( OneWire::crc8( addr, 7) != addr[7]) { Serial.println("CRC not valid!"); delay(1000); return; } } void getTemp() { int foo, bar; ds.reset(); ds.select(addr); ds.write(0x44,1); present = ds.reset(); ds.select(addr); ds.write(0xBE); for ( i = 0; i < 9; i++) { data[i] = ds.read(); } LowByte = data[0]; HighByte = data[1]; TReading = (HighByte << 8) + LowByte; SignBit = TReading & 0x8000; if (SignBit) { TReading = -TReading; } Tc_100 = (6 * TReading) + TReading / 4; // multiply by (100 * 0.0625) or 6.25 Whole = Tc_100 / 100; // separate off the whole and fractional portions Fract = Tc_100 % 100; if (Fract > 49) { if (SignBit) { --Whole; } else { ++Whole; } } if (SignBit) { bar = -1; } else { bar = 1; } // celsius to fahrenheit conversion section foo = ((Whole * bar) * 18); FWhole = (((Whole * bar) * 18) / 10) + 32; // round up if needed if ((foo % 10) > 4) { ++FWhole; } } void printTemp(void) { Serial.print("Temp is: "); if (SignBit) { Serial.print("-"); } Serial.print(Whole); Serial.print(" C / "); Serial.print(FWhole); Serial.println(" F"); } void loop(void) { getTemp(); printTemp(); delay(1000); }