How to connect LM75 thermometer to Raspberry Pi

2019-09-05 | 182 words

We have already shown how to measure the temperature of the processor and receive email notifications when the temperature exceeds a certain threshold.

Now, we will show you how to connect an external thermometer LM75A to Raspberry Pi. It is a module designed to be directly connected to Raspberry Pi.

Hardware connection

Simply insert it into Raspberry Pi like this. Although in practice, you may want to use extension jumper cables so that you can measure the temperature somewhere in the room instead of right next to the processor.

LM75 Software Configuration

And we will continue with the software. First, we need to enable the I2C interface.

sudo raspi-config

Then, we install i2c tools:

sudo apt-get -y install i2c-tools

And with this crazy command, we can display the temperature:

i2cget -y 1 0x48 0x00 w |awk ‘{printf("%0.1f C\n",(a=(((“0x"substr($1,5,2)substr($1,3,1))*0.0625)+0.1) )>128?a-256:a)}’

I was inspired by this article. Personally, I put this command in a cron job that displays the current temperature in an HTML page on a web server. Thanks to this (and port forwarding), I can check the temperature of my apartment anytime.