# Copyright (c) 2012 Matthew Kirk
# Licensed under MIT License, see 
# http://www.cl.cam.ac.uk/freshers/raspberrypi/tutorials/temperature/LICENSE

import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.IN)

while True:
	if GPIO.input(17):
		tfile = open("/sys/bus/w1/devices/10-000802824e58/w1_slave")
		text = tfile.read()
		tfile.close()
		temperature_data = text.split()[-1]
		temperature = float(temperature_data[2:])
		temperature = temperature / 1000
		print temperature
	while GPIO.input(17):
		pass
