Friday, June 7, 2013

Read Dallas iButton Arduino

Requirements:
 
-Arduino board
-OneWire Library (unzip and copy to arduino-1.0.3/libraries)
-Maxim Ibutton DS1990
-Maxim Touch Probe Read
 
 
 Schematic
 
 
 Breadboard Connection

 
Code: 
  
 #include <OneWire.h>

OneWire ibutton (2); // I button connected on PIN 2.

byte buffer[20]; //array to store the Ibutton ID.

void setup(){
 Serial.begin(9600); 
   
}

void loop(){
   
 if (!ibutton.search (buffer)){//read attached ibutton and asign value to buffer
    ibutton.reset_search();
    delay(200);
    return;
 }
  
  for (int x = 0; x<8; x++){  
    Serial.print(buffer[x],HEX); //print the buffer content in LSB. For MSB: for (int x = 8; x>0; x--) 
     Serial.print(" "); // print a space
   }
   Serial.println("\n"); // print new line
   
   //crc compute//
   byte crc;
   crc = ibutton.crc8(buffer, 7);
   Serial.println(crc,HEX);
 
     
} 
 
/*by Elimeléc
 Jun-07-2013
*/ 
 

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.