LM75 Temperature Sensor and Raspberry Pi Rev B


Hello, I have found numerous articles explaining varying methods on attaching this sensor and then registering its drivers but unfortunately I seem to be unable to get these drivers installed. Most instructions use different driver names and so I am confused as to which one to use. I believe I should find the device/sensor registered in /sys/bus but this does not seem to be the case.

I have tried…

sudo modprobe i2c-bcm2708
sudo modprobe i2c-dev

Just returns me to the command prompt with no indication that anything happened

sudo modprobe w1-gpio
sudo modprobe w1-therm

Just returns me to the command prompt with no indication that anything happened

sudo modprobe lm75

Module LM75 not found

I would appreciate being pointed to some instructions that highlights what I am missing. My guess is that the drivers are not being downloaded. I have also performed sudo apt-get update which hasn’t provided any further luck.

Thank-You in advance


Here’s an example script that will poll the LM75 chip and display the temperature it reads the terminal…


while true;


i2cget -y 1 0x48 0x00 w |
awk ‘{printf("%.1f\n", (a=(

sleep 3


You’ll need i2ctools installed for this to work. The LM75 is seen on the i2c line and not as a separate piece of attached hardware so that’s why you weren’t seeing anything back from the other stuff you were doing…


Thank You very much for this. I was wondering if you could explain the awk parsing that is happening. I realise that it is dealing with signed bits to handle negative temps and that Most and Least significant bytes are being worked to give you a result. But I am curious about the 0.0625 and the +0.1. So it would be great insight to understand the maths as well and what it is catering for and how. Again I appreciate your time and response. Cheers


If my memory is correct (often isn’t) that figure is to convert from hex to human readable in the form of degrees Centigrade. Now as for the awk side of it to be honest I didn’t quite work that out myself, and I’ve just done a quick google search to see if I can find the original source of that script but my google foo isn’t that great today and I’ve found heaps of other things that you can do with the lm75!

I only got the lm75 on a whim whilst getting some other things so I’ve not really done much with it at this stage. My future plans are to replace my aging Lacrosse weather station (11 years in the weather so far) with either an arduino or raspberry pi.


Thanks Again. Completely understand. I googled and came across the same plus a few others in Python a few days ago and threw it into our monitoring system. But the maths seems to be subtlety different and I am thinking it is to do with trying to normalise the result or take out some rounding issues.The results I am getting come in an obvious pattern and I am now trying to establish if the A/C in teh server room is really fluctuating like this or if the Pi is heating up as the cpu cycles or if the maths are not correct. I am taking 5 samples 1 second apart every 30 minutes and getting the average and then plotting it. So I am not sure why I get this cyclic pattern. Of course the A/C could be going up and down but since it is a closed room I am suspicious that it is something else. Beyond all of that I am always keen to understand the logic and in this case I am half there.

Here is the Python script that I garnished from the web and then cleaned it up and put my own logic around the sampling as well as customising the output for the PRTG monitoring API.

#!/usr/bin python

import time
import numpy as np
import smbus





BUS_ID = 1
TIMEX = 100
TICK = 15

bus = smbus.SMBus(BUS_ID)
i = 0
result = 0
sample = 0



Probably should get the average of several readings to flatten out

what appears to be spikes in temperature on regular cpu cycles


for i in range(0, MAX_SAMPLES):
data = bus.read_i2c_block_data(REGISTER_ID, 0)
dataMSB = data[0]
dataLSB = data[1]
sample = (((dataMSB << 8) | dataLSB) >>7) * 0.5

# Check for negative temperature
if sample > 125:
    sample =(((((dataMSB << 8) | dataLSB) >>7) * 0.5) -256)
# Adjust result to cater for estimated direct rack and pi heat
sample = sample - ADJUSTMENT
result = result + sample

Calculate Average

result = result / MAX_SAMPLES

Send Result to STDOUT

print “%s:%s:Current Temperature” % (OK,result)

Cheers and thanks again


This is on my to do list! :wink: and I’ve got a few other things that I’m supposed to have done (according to the wife!) I’ve struck a problem with another arduino shield and that’s been a challenge with the total lack of documentation and sketch examples! But this is only a hobby for me so I’m not in any rush…


In the shell script above what is the output value C or F ?

When I run the shells cript I get:

33.n where n is anywhere from 1 to 8.

If I run the Python script I get:

0:5.0:Current Temperature

My real thermometer says: 23.2C




Hi Ken,

The values seemed to be C as they were ‘close’ to the old-school thermometer and a A/C LCD panel in the room that displayed the temp.

As you can see in the script a number of samples was taken and since there was heat leaking from the surrounding equipment and what appeared to be a cycle time fluctuation I tried to flatten it out with a hard-coded adjustment so that I could get the Pi reading similar to the LCD panel on the A/C.

You may not need to do the adjustment or need to do it at the same severity that I have. I am afraid my setup is very rough and ready as accuracy was not a goal rather detecting extremes to indicate the A/C had failed.

I am wondering however if it is a coincidence that your result is “5” (keeping in mind that this script was deliberately written to put put a PRTG out string. So the first %s is the return code and the second %s is the calculated temperature. Without seeing your python code I suspect it may not actually be getting the temp at all. Please take that comment for what it is worth as each environment is different.

Cheers I hope find a solution as it is a great device and has been of great assistance in our setup.


Hi Burce

If you double your reading frequency (15min instead of 30min) do you still get the same pattern. The temperature difference is not very large and appears to be what would be expected with the heating/cooling cycle around a set thermostat.

If you attach a piece of aluminium to the LM75 to help smooth out the changes in temperature. It would make the LM75 react slower to a change in ambient tempearature.


Hi…i think you can simply follow this also: Turn off the Pi—it is generally a bad idea to connect wires while there is electricity running through the pins.Obtain:An AdaFruit ribbon cable connector.A DS18B20 temperature sensor. A 4.7kΩ resistor, a breadboard, and a selection of wires.Solder, and a soldering iron.Solder the ribbon connector parts together, and attach the ribbon cable connector to the Pi and breadboard.Connect pin 3 on the sensor to the 3.3V GPIO pin.Connect pin 1 to the ground GPIO pin. GND on the AdaFruit connector).Connect pin 2 to the GPIO pin 4.Put the 4.7kΩ resistor between pin 2 and pin 3 of the temperature sensor.Turn the Pi on, then put your finger against the sensor.

circuit card assembly