The DS18B20

This is a 1-wire digital themometer.

VCC -> 3.3v

DQ -> GPIO04

GND -> GND

First you need to add one wire support, by adding this line to config.txt:

dtoverlay=w1-gpio

Use:

sudo nano /boot/config.txt

To edit the file.

This little program prints both Celsius and Fahrenheit each second:

Program

Run it with:

sudo python ds18b20.py

And you'll get this output: Output