Exemple #1
0
def readTemperature():
	global temperature
	try:
		basedir = '/sys/bus/w1/devices'
		sensors = ds18b20driver.find_sensors(basedir)
		if not sensors:
			#print "senzor ds18b20 nedetekován"
			return True
		for s in sensors:
			(ok, temp) = ds18b20driver.read_temp(basedir + '/' + s)
			if ok:
				temperature = float("{0:.2f}".format(temp / 1000.0))
				break
	except:
		pass
Exemple #2
0
def readTemperatureOUT():
	global temperature2
	try:
		basedir = '/sys/bus/w1/devices'
		sensors = ds18b20driver.find_sensors(basedir)
		if not sensors:
			#print "senzor ds18b20 nedetekován"
			return False
		for s in sensors:
			(ok, temp) = ds18b20driver.read_temp(basedir + '/' + s)
			if ok:
				teplota = float("{0:.2f}".format(temp / 1000.0))
				temperature2 = int(teplota)
				return True
				break
	except:
		return False
Exemple #3
0
def update_temperature(*args):
  global timer_running, temperature
  try:
    if not timer_running:
		  return False
    basedir = '/sys/bus/w1/devices'
    sensors = ds18b20driver.find_sensors(basedir)
    if not sensors:
        print getNowStr() + "senzor ds18b20 nedetekován"
        return True
    for s in sensors:
        (ok, temp) = ds18b20driver.read_temp(basedir + '/' + s)
        if ok:
            temperature = float("{0:.2f}".format(temp / 1000.0))
            break
    print getNowStr() + "Teplota "+str(temperature) + " °C"
    lcd_display_string("Teplota "+str(temperature)+" °C   ", 1)
  except:
    return timer_running