4       1) set the i2c address of the LM75
 
   5         * R/W pulse at end of address byte not included in address 1-0-0-1-A2-A1-A0
 
   6         * example - all lines to 0V - 1001000 = decimal 72
 
   7       2) calculate the temperature
 
   9         usage :- type (without the < >)
 
  10                 <LM75_address><space><address as decimal>
 
  18 #include <linux/i2c-dev.h>
 
  19 #include <linux/i2c.h>
 
  20 #include <sys/ioctl.h>
 
  23 int main(int argc, char** argv)
 
  25   int address;      /* i2c bus address */
 
  27  if (argc != 2)   /* report error if we are not getting just 1 input after the program name */
 
  29   printf("Error. usage: %s i2c_chip_address\n", argv[0]);
 
  31   address = atoi(argv[1]); /* address is the first number after the program name */
 
  34           int f = open("/dev/i2c-0",O_RDWR);
 
  37               ioctl(f,I2C_SLAVE,address);
 
  38               if (-1 == read(f,buf,2)) {
 
  39                   printf("read error.\n");
 
  40               } else { /* calculate the temperature*/
 
  41                   int temp = buf[0]*256+buf[1];
 
  45                   printf("Temperature (C)\t\t%g\n", (float)temp/2.0);