Connect a DS18b20 temperature sensor to your Raspberry PI as follows. I used a breakout for this. In this example we will just be using terminal commands
Now you need to enter the following at the command prompt:
sudo nano /boot/config.txt
to open the /boot/config.txt file for editing. Then scroll down to the bottom of the file, and add the line:
save the amended file and reboot the Raspberry Pi so that the changes take effect.
Enter the following at a command prompt
sudo modprobe w1-gpio sudo modprobe w1_therm cd /sys/bus/w1/devices/ ls cat /sys/bus/w1/devices/28-0000027a4334/w1_slave
You will see something like the following, the t=20347 is the temperature reading, in this example that is 20.347 celsius