Issue #066 [WontFix/closed] - DS18B20 - Exception thrown in python and webpage

Posted by davidpaulmiller

What steps will reproduce the problem? Symptom: After some time, an exception is thrown via python in both script and http (I presume)

  1. When monitoring DS18B20 temperature, A. In webpage, temperature stops updating - a refresh of page restarts B. In python script, exception is thrown:

Set Temp: 45 Cellar Temp: 46 Cellar temp: Too Warm

Set Temp: 45 Cellar Temp: 46 Cellar temp: Too Warm Traceback (most recent call last): File "/mnt/data/cellar/cellar.py", line 33, in <module> cellar_temp = "%.0f" % (Cellar.getFahrenheit()) File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.6.0-py3.2-linux-armv6l.egg/webiopi/devices/sensor/__init__.py", line 118, in getFahrenheit return self.__getFahrenheit__() File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.6.0-py3.2-linux-armv6l.egg/webiopi/devices/sensor/onewiretemp.py", line 34, in __getFahrenheit__ return self.Celsius2Fahrenheit() File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.6.0-py3.2-linux-armv6l.egg/webiopi/devices/sensor/__init__.py", line 93, in Celsius2Fahrenheit return value * 1.8 + 32

TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'

WebIOPi version used? => 0.6.0 Python version used? => 3

Distro used? (WebIOPi has only been tested on Raspbian Wheezy) => Raspbian Wheezy

Raspberry Pi board revision? (1 or 2) => 2

For Javascript side bugs, Browser? => N/A

Please provide any additional information below.

Python Script:

#

#

Beer Cellar

5-Nov, 2013

cellar.py

#

#

Imports

import webiopi import time import sys import os

GPIO = webiopi.GPIO sys.path.append("/mnt/data/cellar/") from webiopi.devices.sensor import DS18B20

Setup GPIOs

GPIO.setFunction(23, GPIO.OUT) GPIO.output(23, GPIO.LOW) GPIO.output(7, GPIO.LOW)

Enable debug output

webiopi.setDebug()

Cellar = DS18B20 (slave="28-0000043a6d18") loop = 1

while loop == 1: GPIO.output(7, GPIO.HIGH) cellar_temp = "%.0f" % (Cellar.getFahrenheit())

os.system('clear')

fo = open(&quot;/mnt/data/cellar/set\_temp.txt&quot;, &quot;r&quot;)
set\_temp = fo.read(2);
fo.close()

print ('\n' + &quot;Set Temp: &quot; + set\_temp)
print (&quot;Cellar Temp: &quot; + cellar\_temp)

if cellar\_temp &gt; set\_temp:
    print (&quot;Cellar temp: Too Warm&quot;)
    GPIO.output(23, GPIO.HIGH)

else:
    print (&quot;Cellar temp: Too Cold&quot;)
    GPIO.output(23, GPIO.LOW)

time.sleep (5)
GPIO.output(7, GPIO.LOW)
time.sleep (5)
GPIO.output(7, GPIO.HIGH)

time.sleep (5)
GPIO.output(7, GPIO.LOW)
time.sleep (5)
GPIO.output(7, GPIO.HIGH)

time.sleep (5)
GPIO.output(7, GPIO.LOW)
time.sleep (5)
GPIO.output(7, GPIO.HIGH)

@webiopi.macro def Temp(arg0):

return (&quot;%s&quot; % (cellar\_temp))


Comment 1

Posted by trouch

see issue 68