2 #include <DallasTemperature.h>
4 /* DS18S20 Temperature chip i/o */
7 DallasTemperature sensors(&ds);
9 DeviceAddress insideThermometer = { 0x10, 0xE7, 0x77, 0xD3, 0x01, 0x08, 0x00, 0x3F };
11 void printTemperature(DeviceAddress deviceAddress)
13 float tempC = sensors.getTempC(deviceAddress);
14 Serial.print("Temp C: ");
16 Serial.print(" Temp F: ");
17 Serial.println(DallasTemperature::toFahrenheit(tempC)); // Converts tempC to Fahrenheit
31 printTemperature(insideThermometer);
38 if ( !ds.search(addr)) {
39 Serial.print("\nNo more addresses.\n");
46 for( i = 0; i < 8; i++) {
47 Serial.print(addr[i], HEX);
51 if ( OneWire::crc8( addr, 7) != addr[7]) {
52 Serial.print(" CRC is not valid!\n");
56 if ( addr[0] != 0x10) {
57 Serial.print("\nDevice is not a DS18S20 family device.\n");
61 // The DallasTemperature library can do all this work for you!
65 ds.write(0x44,1); // start conversion, with parasite power on at the end
67 delay(1000); // maybe 750ms is enough, maybe not
68 // we might do a ds.depower() here, but the reset will take care of it.
72 ds.write(0xBE); // Read Scratchpad
75 Serial.print(present,HEX);
77 for ( i = 0; i < 9; i++) { // we need 9 bytes
79 Serial.print(data[i], HEX);
83 Serial.print(" CRC=");
84 Serial.print( OneWire::crc8( data, 8), HEX);