# HG changeset patch # User Matt Johnston # Date 1356013482 -28800 # Node ID e114b38c8a559a7e93b555cc3074e6b17b3ffb13 # Parent d686b111dab427ee764f84f8a5d6ba7086293612 internal temperature sensor diff -r d686b111dab4 -r e114b38c8a55 py/config.py --- a/py/config.py Sun Dec 16 22:14:46 2012 +0800 +++ b/py/config.py Thu Dec 20 22:24:42 2012 +0800 @@ -12,3 +12,4 @@ FRIDGE_GPIO = '/sys/devices/virtual/gpio/gpio17' WORT_NAME = '28-0000031abc49' FRIDGE_NAME = 'bb' +INTERNAL_TEMPERATURE = '/sys/class/thermal/thermal_zone0/temp' diff -r d686b111dab4 -r e114b38c8a55 py/sensor_ds18b20.py --- a/py/sensor_ds18b20.py Sun Dec 16 22:14:46 2012 +0800 +++ b/py/sensor_ds18b20.py Thu Dec 20 22:24:42 2012 +0800 @@ -19,6 +19,19 @@ self.readthread = gevent.threadpool.ThreadPool(1) self.master_dir = config.SENSOR_BASE_DIR + def do(self): + vals = {} + for n in self.sensor_names(): + value = self.do_sensor(n) + if value is not None: + vals[n] = value + + itemp = self.do_internal() + if itemp: + vals['internal'] = itemp + + self.server.add_reading(vals) + def _run(self): while True: self.do() @@ -52,14 +65,13 @@ EX("Problem reading sensor '%s': %s" % (s, str(e))) return None - def do(self): - vals = {} - for n in self.sensor_names(): - value = self.do_sensor(n) - if value is not None: - vals[n] = value - - self.server.add_reading(vals) + def do_internal(self): + try: + return int(open(config.INTERNAL_TEMPERATURE, 'r').read()) / 1000.0 + except Exception, e: + EX("Problem reading internal sensor: %s" % str(e)) + return None + def sensor_names(self): """ Returns a sequence of sensorname """