#!/us'>r/bin/python # Copyright Nigel Brooke 12/23/2013 import os import time import threading import smbus Sensors = [ 'LM75 Raspberry Pi', 'Thermocouple Raspberry pi','EOF'] Period = 1 Displaylines = 10 Lines = 0 def Readsensor(): Sensortype ={ 0:ReadLM75, 1:ReadThermocouple, 2:ReadUSBLM75, 3:ReadADC, } Sensortype[Selection]() def ReadLM75(): #Note this is set up for a Rev A raspberry pi the SMBus address will need to be changed for a Rev B Device global Data global Units Units = "Deg C" bus = smbus.SMBus(0) busdata = bus.read_i2c_block_data(0x48, 0) TempMSB = busdata[0] TempLSB = busdata[1] Data = (((TempMSB << 8) | TempLSB) >>7) * 0.5 def ReadThermocouple(): global Data Data = 10 def ReadUSBLM75(): global Data Data = 15 def ReadADC(): global Data Data = 20 def cls(): os.system('clear') def Listsensors(): global Selection i=0 print "************" print "**PiLogger**" print "************" print "" while(Sensors[i] != 'EOF'): print i,' ',Sensors[i] i=i+1 done = True while (done): print "" Selection = raw_input("Please select sensor by typing number:- ") try: Selection = int(Selection) if (0<= Selection <=i-1): print "Sensor selected:- ",Sensors[Selection] done = False else: print "Enter valid value" except: continue def Tick(Secs): Starttime = time.time() while((time.time()-Starttime)