#Python Program to read DH18B20 temperature sensor into Raspberry Pi 2 #Project circuit graph and tutorial url -- http://osoyoo.com/?p=728 import time while 1: tempfile = open ("/sys/bus/w1/devices/28-0000050496de/w1_slave") #please replace 28-0000050496de with your sensor address from tutorial step 5 thetext = tempfile.read() tempfile.close() tempdata = thetext.split("\n")[1].split(" ")[9] temperature = float(tempdata[2:]) temperature = temperature /1000 print temperature