neiltechspec
Senior Member
Using a HT21D i2c Humidity & Temp sensor, no probs with Humidity & Temp in degrees C.
But I can't seen to get my head around converting negative degrees C to degrees F.
Any help appreciated, relevant part of code is below (with below 0 remmed out).
Neil.
But I can't seen to get my head around converting negative degrees C to degrees F.
Any help appreciated, relevant part of code is below (with below 0 remmed out).
Neil.
Code:
symbol temp12 = w7
symbol adjtemp = w8
HTUtemp:
hi2cin $e3,(b15,b14) ;temperature measurement
temp12 = temp12 & $FFFC ;mask out lower 2 bits of LSB (status bits)
temp12 = 17572 ** temp12 - 4685
tempf = temp12 ;for Fahrenheit conversion
sign = 43 ;"+"
if temp12 > 13000 then ;check for below 0
sign = 45 ;"-"
temp12 = - temp12
endif
bintoascii temp12,b23,b24,b25,b26,b27
if b24 = 48 then
serout ip_out,baud,("S Panel Temp: ",sign,b25,".",b26,$b0,"C",cr,lf)
endif
if b24 > 48 then
serout ip_out,baud,("S Panel Temp: ",sign,b24,b25,".",b26,$b0,"C",cr,lf)
endif
;Fahrenheit Conversion
if tempf <= 13000 then
adjtemp = tempf * 9 / 5 + 3200
endif
;if tempf > 13000 then
;tempf = tempf - 13000
;adjtemp = tempf * 9 / 5 - 3200
;endif
;bintoascii adjtemp,b23,b24,b25,b26,b27
;serout ip_out,baud,(" ",b24,b25,".",b26,$b0,"F",cr,lf)