# ___ ___ ___ _ _ ___ ___ ____ ___ ____ # / _ \ /___)/ _ \| | | |/ _ \ / _ \ / ___) _ \| \ #| |_| |___ | |_| | |_| | |_| | |_| ( (__| |_| | | | | # \___/(___/ \___/ \__ |\___/ \___(_)____)___/|_|_|_| # (____/ # #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