Certain negative temperatures don't register - need help!
Posted: Fri Jan 03, 2014 3:23 pm
Hi,
I'm trying to follow this tutorial:
http://raspberrywebserver.com/cgiscript ... ogger.html
However, there is a problem: whenever a temperature goes below -10 degrees the minus disappears and it looks like if it it's a positive temperature.

The full code is here:
https://github.com/Pyplate/rpi_temp_log ... monitor.py
and I think the part responsible for converting the data from the sensor to a number is this one:
Can anyone please help me solve this? Thanks!
I'm trying to follow this tutorial:
http://raspberrywebserver.com/cgiscript ... ogger.html
However, there is a problem: whenever a temperature goes below -10 degrees the minus disappears and it looks like if it it's a positive temperature.

The full code is here:
https://github.com/Pyplate/rpi_temp_log ... monitor.py
and I think the part responsible for converting the data from the sensor to a number is this one:
Code: Select all
# get temerature
# returns None on error, or the temperature as a float
def get_temp(devicefile):
try:
fileobj = open(devicefile,'r')
lines = fileobj.readlines()
fileobj.close()
except:
return None
# get the status from the end of line 1
status = lines[0][-4:-1]
# is the status is ok, get the temperature from line 2
if status=="YES":
print status
tempstr= lines[1][-6:-1]
tempvalue=float(tempstr)/1000
print tempvalue
return tempvalue
else:
print "There was an error."
return None