#include OneWire ds(10); // on pin 10 void setup(void) { Serial.begin(9600); } void loop(void) { byte i; byte present = 0; byte data[12]; byte addr[8]; float celsius; //searching if the ibutton is connected ds.reset_search(); if ( !ds.search(addr)) { Serial.print("No more addresses.\n"); ds.reset_search(); return; } //checking crc if ( OneWire::crc8( addr, 7) != addr[7]) { Serial.print("CRC is not valid!\n"); return; } //taking readings //first stage is to convert the data by selecting the reg 33 ds.reset(); ds.select(addr); ds.write(0x44,1); // start conversion, with parasite power on at the end //giving enough time for the conversion delay(1000); //second stage is to read from scratchpad of the address 0f ds.reset(); ds.select(addr); ds.write(0xAA); // Read Scratchpad //fitching and printing data Serial.print("d = "); for ( i = 0; i < 9; i++) { // we need 9 bytes data[i] = ds.read(); Serial.print(data[i],HEX); Serial.print(" ");} Serial.print('\n'); celsius = (((float)data[1] / 2.0f) - 41.0f) + ((float)data[0] / 512.0f); Serial.print("16 bit Celu= "); Serial.print(celsius); Serial.print(" CRC="); Serial.print( OneWire::crc8( data,7), HEX); Serial.println();}