The one I'm currently using is the DS18B20.
First open the Pi and type:
sudo leafpad /etc/apt/sources.list.d/raspi.list
Then add the word untested
after main
.
Then type:
sudo apt-get update
sudo apt-get upgrade
In my case it took a long time, though it depends on your wifi/ethernet speed.
After that, you reboot:
sudo reboot now
Connect the white wire to GPIO4, The red wire to 3V3, and the black to GND. You also connect a 4.7K resistor between the white and red wires.
You can read it by doing the following commands:
sudo modprobe w1-gpio
sudo modprobe w1-therm
cd /sys/bus/w1/devices/
ls
Then is should list the serial number of the temperature sensor, followed by w1_bus_master1
Then go:
cd serial-number-here
cat w1_slave
And then it should show 2 lines of code, where the 5 digits at the end of the second line are the temperature.
This utilizes something called the "Dallas One-Wire Temperature Sensor Protocol", or something.