LM75 Temperature Sensor

The LM75 [1] is an I2C temperature sensor from Texas Instruments with an accuracy ±2 °C from -25 °C to 100 °C and ±3 °C over –55 °C to 125 °C. It has a resolution of 0.5 °C and can be powered from 3 V to 5.5 V.

You can mount the chip yourself on an SOIC-8 breakout board:

LM75.jpg

Three address inputs are provided, to allow you to choose one of eight I2C addresses; the default address, with all lines connected to GND, is #x48 or 72.

Reading the temperature

The following routine reads the temperature and returns it as an integer, in 1/2ths of a degree Celsius:

(defun lm75-temp ()
  (with-i2c (str #x48) 
    (write-byte 0 str)
    (restart-i2c str 2)
    (let* ((hi (read-byte str))
           (lo (read-byte str))
           (tmp (logior (ash hi 1) (ash lo -7))))
      (- (logand tmp #x00FF) (logand tmp #x0100)))))

To return the temperature as an integer number of degrees, or a floating-point number on a 32-bit version of uLisp, do:

(/ (lm75-temp) 2)

  1. ^ LM75 Datasheet on Texas Instruments.